Skip to content

Commit

Permalink
Merge pull request #27 from Umfi/master
Browse files Browse the repository at this point in the history
Add adaptive icon support in PWAs with maskable icons
  • Loading branch information
silviolleite authored Apr 24, 2020
2 parents 82b84b3 + 8498463 commit c0ec0c4
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 24 deletions.
40 changes: 32 additions & 8 deletions Config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,38 @@
'orientation'=> 'any',
'status_bar'=> 'black',
'icons' => [
'72x72' => '/images/icons/icon-72x72.png',
'96x96' => '/images/icons/icon-96x96.png',
'128x128' => '/images/icons/icon-128x128.png',
'144x144' => '/images/icons/icon-144x144.png',
'152x152' => '/images/icons/icon-152x152.png',
'192x192' => '/images/icons/icon-192x192.png',
'384x384' => '/images/icons/icon-384x384.png',
'512x512' => '/images/icons/icon-512x512.png'
'72x72' => [
'path' => '/images/icons/icon-72x72.png',
'purpose' => 'any'
],
'96x96' => [
'path' => '/images/icons/icon-96x96.png',
'purpose' => 'any'
],
'128x128' => [
'path' => '/images/icons/icon-128x128.png',
'purpose' => 'any'
],
'144x144' => [
'path' => '/images/icons/icon-144x144.png',
'purpose' => 'any'
],
'152x152' => [
'path' => '/images/icons/icon-152x152.png',
'purpose' => 'any'
],
'192x192' => [
'path' => '/images/icons/icon-192x192.png',
'purpose' => 'any'
],
'384x384' => [
'path' => '/images/icons/icon-384x384.png',
'purpose' => 'any'
],
'512x512' => [
'path' => '/images/icons/icon-512x512.png',
'purpose' => 'any'
],
],
'splash' => [
'640x1136' => '/images/icons/splash-640x1136.png',
Expand Down
48 changes: 36 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Laravel (PWA) Progressive Web Aplication
# Laravel (PWA) Progressive Web Aplication

[![Laravel 5.x](https://img.shields.io/badge/Laravel-5.x-orange.svg)](http://laravel.com)
[![Latest Stable Version](https://poser.pugx.org/silviolleite/laravelpwa/v/stable)](https://packagist.org/packages/silviolleite/laravelpwa)
Expand Down Expand Up @@ -53,14 +53,38 @@ Configure your app name, description, icons and splashes in `config/laravelpwa.
'orientation' => 'any',
'status_bar' => 'black',
'icons' => [
'72x72' => '/images/icons/icon-72x72.png',
'96x96' => '/images/icons/icon-96x96.png',
'128x128' => '/images/icons/icon-128x128.png',
'144x144' => '/images/icons/icon-144x144.png',
'152x152' => '/images/icons/icon-152x152.png',
'192x192' => '/images/icons/icon-192x192.png',
'384x384' => '/images/icons/icon-384x384.png',
'512x512' => '/images/icons/icon-512x512.png',
'72x72' => [
'path' => '/images/icons/icon-72x72.png',
'purpose' => 'any'
],
'96x96' => [
'path' => '/images/icons/icon-96x96.png',
'purpose' => 'any'
],
'128x128' => [
'path' => '/images/icons/icon-128x128.png',
'purpose' => 'any'
],
'144x144' => [
'path' => '/images/icons/icon-144x144.png',
'purpose' => 'any'
],
'152x152' => [
'path' => '/images/icons/icon-152x152.png',
'purpose' => 'any'
],
'192x192' => [
'path' => '/images/icons/icon-192x192.png',
'purpose' => 'any'
],
'384x384' => [
'path' => '/images/icons/icon-384x384.png',
'purpose' => 'any'
],
'512x512' => [
'path' => '/images/icons/icon-512x512.png',
'purpose' => 'any'
],
],
'splash' => [
'640x1136' => '/images/icons/splash-640x1136.png',
Expand Down Expand Up @@ -144,7 +168,7 @@ how this example:
// Initialize the service worker
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/serviceworker.js', {
scope: '.'
scope: '.'
}).then(function (registration) {
// Registration was successful
console.log('Laravel PWA: ServiceWorker registration successful with scope: ', registration.scope);
Expand Down Expand Up @@ -249,7 +273,7 @@ By default, the offline view is implemented in `resources/views/vendor/laravelpw
@endsection
```
To customize update this file.

## Contributing

Contributing is easy! Just fork the repo, make your changes then send a pull request on GitHub. If your PR is languishing in the queue and nothing seems to be happening, then send Silvio an [email](mailto:[email protected]).
Contributing is easy! Just fork the repo, make your changes then send a pull request on GitHub. If your PR is languishing in the queue and nothing seems to be happening, then send Silvio an [email](mailto:[email protected]).
9 changes: 5 additions & 4 deletions Services/ManifestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ public function generate()
];

foreach (config('laravelpwa.manifest.icons') as $size => $file) {
$fileInfo = pathinfo($file);
$fileInfo = pathinfo($file['path']);
$basicManifest['icons'][] = [
'src' => $file,
'src' => $file['path'],
'type' => 'image/' . $fileInfo['extension'],
'sizes' => $size
'sizes' => $size,
'purpose' => $file['purpose']
];
}

Expand All @@ -40,4 +41,4 @@ public function generate()
return $basicManifest;
}

}
}

0 comments on commit c0ec0c4

Please sign in to comment.