Skip to content

Commit

Permalink
App Icon version 2 (#103)
Browse files Browse the repository at this point in the history
* Alt implementation

* Fix styling

---------

Co-authored-by: simonhamp <[email protected]>
  • Loading branch information
simonhamp and simonhamp authored Sep 2, 2024
1 parent 1080f97 commit 2aa9813
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Commands/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
use Illuminate\Support\Str;
use Native\Electron\Concerns\LocatesPhpBinary;
use Native\Electron\Facades\Updater;
use Native\Electron\Traits\InstallsAppIcon;
use Native\Electron\Traits\OsAndArch;

class BuildCommand extends Command
{
use InstallsAppIcon;
use LocatesPhpBinary;
use OsAndArch;

Expand Down Expand Up @@ -40,13 +42,15 @@ public function handle(): void
// Added checks for correct input for os and arch
$os = $this->selectOs($this->argument('os'));

$this->installIcon();

$buildCommand = 'build';
if ($os != 'all') {
$arch = $this->selectArchitectureForOs($os, $this->argument('arch'));

$os .= $arch != 'all' ? "-{$arch}" : '';

// Wether to publish the app or not
// Should we publish?
if ($publish = ($this->option('publish'))) {
$buildCommand = 'publish';
}
Expand Down
5 changes: 4 additions & 1 deletion src/Commands/DevelopCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
use Illuminate\Console\Command;
use Native\Electron\Traits\Developer;
use Native\Electron\Traits\Installer;
use Native\Electron\Traits\InstallsAppIcon;

use function Laravel\Prompts\intro;
use function Laravel\Prompts\note;

class DevelopCommand extends Command
{
use Developer, Installer;
use Developer, Installer, InstallsAppIcon;

protected $signature = 'native:serve {--no-queue} {--D|no-dependencies} {--installer=npm}';

Expand All @@ -36,6 +37,8 @@ public function handle(): void

$this->patchPackageJson();

$this->installIcon();

$this->runDeveloper(installer: $this->option('installer'), skip_queue: $this->option('no-queue'));
}

Expand Down
20 changes: 20 additions & 0 deletions src/Traits/InstallsAppIcon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Native\Electron\Traits;

use function Laravel\Prompts\intro;
use function Laravel\Prompts\note;

trait InstallsAppIcon
{
public function installIcon()
{
intro('Copying app icons...');

@copy(public_path('icon.png'), __DIR__.'/../../resources/js/resources/icon.png');
@copy(public_path('IconTemplate.png'), __DIR__.'/../../resources/js/resources/IconTemplate.png');
@copy(public_path('[email protected]'), __DIR__.'/../../resources/js/resources/[email protected]');

note('App icons copied');
}
}

0 comments on commit 2aa9813

Please sign in to comment.