Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ _ide_helper.php
Homestead.json
Homestead.yaml
Thumbs.db
/nativephp

/database/database.sqlite
/app-release-signed.apk*
/my-release-key*

# Credential files (keystores, private keys, etc.)
/credentials/
41 changes: 28 additions & 13 deletions app/Livewire/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

use App\Enum\BeepLeadIn;
use App\Models\Setting;
use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Rules\Enum;
use Illuminate\View\View;
use Livewire\Attributes\Layout;
use Livewire\Attributes\Title;
use Livewire\Component;
use Nbucic\AudioTts\AudioTTS;

#[Layout('layouts.app')]
#[Title('Settings — Interval Timer')]
Expand All @@ -29,10 +31,10 @@ public function mount(): void
$settings = Setting::current();

$this->defaultBeepLeadIn = $settings->default_beep_lead_in;
$this->defaultEndSound = $settings->default_end_sound;
$this->soundMode = $settings->sound_mode;
$this->volume = $settings->volume;
$this->keepScreenOn = $settings->keep_screen_on;
$this->defaultEndSound = $settings->default_end_sound;
$this->soundMode = $settings->sound_mode;
$this->volume = $settings->volume;
$this->keepScreenOn = $settings->keep_screen_on;
}

public function render(): View
Expand All @@ -44,24 +46,37 @@ public function save(): void
{
$this->validate([
'defaultBeepLeadIn' => ['required', new Enum(BeepLeadIn::class)],
'defaultEndSound' => 'required|in:triple,chime',
'soundMode' => 'required|in:beep,voice',
'volume' => 'required|numeric|min:0|max:1',
'keepScreenOn' => 'boolean',
'defaultEndSound' => 'required|in:triple,chime',
'soundMode' => 'required|in:beep,voice',
'volume' => 'required|numeric|min:0|max:1',
'keepScreenOn' => 'boolean',
]);

$settings = Setting::current();

$settings->default_beep_lead_in = $this->defaultBeepLeadIn;
$settings->default_end_sound = $this->defaultEndSound;
$settings->sound_mode = $this->soundMode;
$settings->volume = round((float) $this->volume, 2);
$settings->keep_screen_on = $this->keepScreenOn;
$settings->default_end_sound = $this->defaultEndSound;
$settings->sound_mode = $this->soundMode;
$settings->volume = round((float)$this->volume, 2);
$settings->keep_screen_on = $this->keepScreenOn;

$settings->save();

$this->dispatch('settingsLoaded', soundMode: $this->soundMode, volume: $this->volume, program: null);
$this->dispatch('settingsLoaded', soundMode: $this->soundMode, volume: $this->volume, keepScreenOn: $this->keepScreenOn, program: null);

$this->saved = true;
}

public function updateAndTest(string $soundMode): void
{
Log::info('Updating settings and testing voice mode...');
$this->soundMode = $soundMode;
if ($soundMode === 'voice') {
\Nbucic\AudioTts\Facades\AudioTTS::speak('Where is Darth Vader now?', 1.0);
// $this->dispatch('playVoiceSound', reason: 'test');
} else {
$this->dispatch('playBeepSound', sound: 'chime');
}
Log::info('Updating settings and testing voice mode... [DONE]');
}
}
6 changes: 4 additions & 2 deletions app/Livewire/TimerScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class TimerScreen extends Component
public string $soundMode = 'beep';
public float $volume = 0.8;
public string $endSound = 'triple';
public bool $keepScreenOn = true;

// ── Ring countdown ────────────────────────────────────────────────────
public int $programTotalDuration = 0;
Expand All @@ -57,8 +58,9 @@ class TimerScreen extends Component
public function mount(?string $id = null): void
{
$settings = Setting::current();
$this->soundMode = $settings->sound_mode;
$this->volume = $settings->volume;
$this->soundMode = $settings->sound_mode;
$this->volume = $settings->volume;
$this->keepScreenOn = $settings->keep_screen_on;

if ($id) {
$this->loadProgram($id);
Expand Down
13 changes: 12 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace App\Providers;

use App\Timer\TimerRunner;
use Database\Seeders\DatabaseSeeder;
use Illuminate\Support\ServiceProvider;
use Throwable;

class AppServiceProvider extends ServiceProvider
{
Expand All @@ -20,6 +22,15 @@ public function register(): void
*/
public function boot(): void
{
//
// On the first installation (empty programs table) seed the demo HIIT program.
// The guard inside DatabaseSeeder::run() makes this idempotent.
// Wrapped in try/catch: during `artisan migrate` the program table
// does not yet exist when the service provider boots — swallow that
// gracefully and let the seeder succeed on the next boot.
try {
(new DatabaseSeeder)->run();
} catch (Throwable $e) {
report($e);
}
}
}
42 changes: 42 additions & 0 deletions app/Providers/NativeServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Nbucic\AudioTts\AudioTTSServiceProvider;

class NativeServiceProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
//
}

/**
* Bootstrap services.
*/
public function boot(): void
{
//
}

/**
* The NativePHP plugins to enable.
*
* Only plugins listed here will be compiled into your native builds.
* This is a security measure to prevent transitive dependencies from
* automatically registering plugins without your explicit consent.
*
* @return array<int, class-string<\Illuminate\Support\ServiceProvider>>
*/
public function plugins(): array
{
return [
AudioTTSServiceProvider::class,

];
}
}
16 changes: 14 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@
"laravel/pail": "^1.2.5",
"laravel/pint": "^1.27",
"mockery/mockery": "^1.6",
"nbucic/audio-tts": "*@dev",
"nunomaduro/collision": "^8.6",
"pestphp/pest": "^4.0",
"pestphp/pest-plugin-laravel": "^4.0",
"phpunit/phpunit": "^12.5.12"
},
"autoload": {
"psr-4": {
"App\\": "app/"
"App\\": "app/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
Expand All @@ -54,6 +56,10 @@
"@php artisan config:clear --ansi",
"@php artisan test"
],
"build": [
"@php artisan config:clear --ansi",
"@php artisan native:package android"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
Expand Down Expand Up @@ -88,5 +94,11 @@
}
},
"minimum-stability": "stable",
"prefer-stable": true
"prefer-stable": true,
"repositories": [
{
"type": "path",
"url": "/home/nikola/projects/private/interval-timer-nativephp/packages/nbucic/audio-tts"
}
]
}
Loading
Loading