gestione comunità
This commit is contained in:
@@ -11,7 +11,14 @@ export class SettingsService {
|
||||
public fullscreenMode = signal<boolean>(false);
|
||||
|
||||
/** Browser Fullscreen state: true = fullscreen active */
|
||||
public browserFullscreen = signal<boolean>(!!document.fullscreenElement);
|
||||
public browserFullscreen = signal<boolean>(
|
||||
!!(
|
||||
document.fullscreenElement ||
|
||||
(document as any).webkitFullscreenElement ||
|
||||
(document as any).mozFullScreenElement ||
|
||||
(document as any).msFullscreenElement
|
||||
)
|
||||
);
|
||||
|
||||
/** Avanzamento automatico: true = passa al brano successivo automaticamente */
|
||||
public autoAdvance = signal<boolean>(true);
|
||||
@@ -22,6 +29,12 @@ export class SettingsService {
|
||||
/** Schermo sempre acceso: true = attiva Screen Wake Lock */
|
||||
public keepScreenOn = signal<boolean>(false);
|
||||
|
||||
/** Funzionalità Comunità: true = il chip comunità è visibile nella home */
|
||||
public comunitaEnabled = signal<boolean>(true);
|
||||
|
||||
/** Invio dati statistici: true = invia pacchetto dati statistici */
|
||||
public invioDatiStatistici = signal<boolean>(false);
|
||||
|
||||
private wakeLock: any = null;
|
||||
|
||||
constructor() {
|
||||
@@ -53,10 +66,31 @@ export class SettingsService {
|
||||
this.keepScreenOn.set(savedKeepScreenOn === 'true');
|
||||
}
|
||||
|
||||
// Sync browser fullscreen state with listeners
|
||||
document.addEventListener('fullscreenchange', () => {
|
||||
this.browserFullscreen.set(!!document.fullscreenElement);
|
||||
});
|
||||
const savedComunitaEnabled = localStorage.getItem('comunita-enabled');
|
||||
if (savedComunitaEnabled !== null) {
|
||||
this.comunitaEnabled.set(savedComunitaEnabled === 'true');
|
||||
}
|
||||
|
||||
const savedStats = localStorage.getItem('invio-dati-statistici');
|
||||
if (savedStats !== null) {
|
||||
this.invioDatiStatistici.set(savedStats === 'true');
|
||||
}
|
||||
|
||||
// Sync browser fullscreen state with listeners (supporting vendor prefixes)
|
||||
const updateFullscreenState = () => {
|
||||
const isFs = !!(
|
||||
document.fullscreenElement ||
|
||||
(document as any).webkitFullscreenElement ||
|
||||
(document as any).mozFullScreenElement ||
|
||||
(document as any).msFullscreenElement
|
||||
);
|
||||
this.browserFullscreen.set(isFs);
|
||||
};
|
||||
|
||||
document.addEventListener('fullscreenchange', updateFullscreenState);
|
||||
document.addEventListener('webkitfullscreenchange', updateFullscreenState);
|
||||
document.addEventListener('mozfullscreenchange', updateFullscreenState);
|
||||
document.addEventListener('MSFullscreenChange', updateFullscreenState);
|
||||
|
||||
effect(() => {
|
||||
localStorage.setItem('show-chords-default', this.showChordsDefault().toString());
|
||||
@@ -110,6 +144,12 @@ export class SettingsService {
|
||||
this.keepScreenOn.update(v => !v);
|
||||
}
|
||||
|
||||
toggleComunitaEnabled() {
|
||||
const newValue = !this.comunitaEnabled();
|
||||
this.comunitaEnabled.set(newValue);
|
||||
localStorage.setItem('comunita-enabled', newValue.toString());
|
||||
}
|
||||
|
||||
private async requestWakeLock() {
|
||||
if ('wakeLock' in navigator) {
|
||||
try {
|
||||
@@ -128,14 +168,41 @@ export class SettingsService {
|
||||
}
|
||||
|
||||
toggleBrowserFullscreen() {
|
||||
if (!document.fullscreenElement) {
|
||||
document.documentElement.requestFullscreen().catch(err => {
|
||||
console.error(`Error attempting to enable full-screen mode: ${err.message}`);
|
||||
});
|
||||
const isFs = !!(
|
||||
document.fullscreenElement ||
|
||||
(document as any).webkitFullscreenElement ||
|
||||
(document as any).mozFullScreenElement ||
|
||||
(document as any).msFullscreenElement
|
||||
);
|
||||
|
||||
if (!isFs) {
|
||||
const docEl = document.documentElement as any;
|
||||
if (docEl.requestFullscreen) {
|
||||
docEl.requestFullscreen().catch((err: any) => console.error(err));
|
||||
} else if (docEl.webkitRequestFullscreen) {
|
||||
docEl.webkitRequestFullscreen();
|
||||
} else if (docEl.mozRequestFullScreen) {
|
||||
docEl.mozRequestFullScreen();
|
||||
} else if (docEl.msRequestFullscreen) {
|
||||
docEl.msRequestFullscreen();
|
||||
}
|
||||
} else {
|
||||
if (document.exitFullscreen) {
|
||||
document.exitFullscreen();
|
||||
const doc = document as any;
|
||||
if (doc.exitFullscreen) {
|
||||
doc.exitFullscreen().catch((err: any) => console.error(err));
|
||||
} else if (doc.webkitExitFullscreen) {
|
||||
doc.webkitExitFullscreen();
|
||||
} else if (doc.mozCancelFullScreen) {
|
||||
doc.mozCancelFullScreen();
|
||||
} else if (doc.msExitFullscreen) {
|
||||
doc.msExitFullscreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
toggleInvioDatiStatistici() {
|
||||
const newValue = !this.invioDatiStatistici();
|
||||
this.invioDatiStatistici.set(newValue);
|
||||
localStorage.setItem('invio-dati-statistici', newValue.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user