commit
dadc18951a
File diff suppressed because it is too large
Load Diff
|
|
@ -12,6 +12,11 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
-->
|
-->
|
||||||
|
<div class="ml-auto">
|
||||||
|
<button class="btn btn-outline-light button-toggle-theme" aria-label="Toggle theme" (click)="themeChanged()">
|
||||||
|
<fa-icon [icon]="darkMode ? faSun : faMoon"></fa-icon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<main role="main" class="container">
|
<main role="main" class="container">
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
.button-toggle-theme:focus, .button-toggle-theme:active
|
||||||
|
box-shadow: none
|
||||||
|
outline: 0px
|
||||||
|
|
||||||
.add-url-box
|
.add-url-box
|
||||||
max-width: 720px
|
max-width: 720px
|
||||||
margin: 4rem auto
|
margin: 4rem auto
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { Component, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
|
import { Component, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
|
||||||
import { faTrashAlt, faCheckCircle, faTimesCircle } from '@fortawesome/free-regular-svg-icons';
|
import { faTrashAlt, faCheckCircle, faTimesCircle } from '@fortawesome/free-regular-svg-icons';
|
||||||
import { faRedoAlt } from '@fortawesome/free-solid-svg-icons';
|
import { faRedoAlt, faSun, faMoon } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { CookieService } from 'ngx-cookie-service';
|
import { CookieService } from 'ngx-cookie-service';
|
||||||
|
|
||||||
import { DownloadsService, Status } from './downloads.service';
|
import { DownloadsService, Status } from './downloads.service';
|
||||||
|
|
@ -19,6 +19,7 @@ export class AppComponent implements AfterViewInit {
|
||||||
quality: string;
|
quality: string;
|
||||||
format: string;
|
format: string;
|
||||||
addInProgress = false;
|
addInProgress = false;
|
||||||
|
darkMode: boolean;
|
||||||
|
|
||||||
@ViewChild('queueMasterCheckbox') queueMasterCheckbox: MasterCheckboxComponent;
|
@ViewChild('queueMasterCheckbox') queueMasterCheckbox: MasterCheckboxComponent;
|
||||||
@ViewChild('queueDelSelected') queueDelSelected: ElementRef;
|
@ViewChild('queueDelSelected') queueDelSelected: ElementRef;
|
||||||
|
|
@ -31,12 +32,15 @@ export class AppComponent implements AfterViewInit {
|
||||||
faCheckCircle = faCheckCircle;
|
faCheckCircle = faCheckCircle;
|
||||||
faTimesCircle = faTimesCircle;
|
faTimesCircle = faTimesCircle;
|
||||||
faRedoAlt = faRedoAlt;
|
faRedoAlt = faRedoAlt;
|
||||||
|
faSun = faSun;
|
||||||
|
faMoon = faMoon;
|
||||||
|
|
||||||
constructor(public downloads: DownloadsService, private cookieService: CookieService) {
|
constructor(public downloads: DownloadsService, private cookieService: CookieService) {
|
||||||
this.format = cookieService.get('metube_format') || 'any';
|
this.format = cookieService.get('metube_format') || 'any';
|
||||||
// Needs to be set or qualities won't automatically be set
|
// Needs to be set or qualities won't automatically be set
|
||||||
this.setQualities()
|
this.setQualities()
|
||||||
this.quality = cookieService.get('metube_quality') || 'best';
|
this.quality = cookieService.get('metube_quality') || 'best';
|
||||||
|
this.setupTheme(cookieService)
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
|
|
@ -67,6 +71,27 @@ export class AppComponent implements AfterViewInit {
|
||||||
this.cookieService.set('metube_quality', this.quality, { expires: 3650 });
|
this.cookieService.set('metube_quality', this.quality, { expires: 3650 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupTheme(cookieService) {
|
||||||
|
if (cookieService.check('metube_dark')) {
|
||||||
|
this.darkMode = cookieService.get('metube_dark') === "true"
|
||||||
|
} else {
|
||||||
|
this.darkMode = window.matchMedia("prefers-color-scheme: dark").matches
|
||||||
|
}
|
||||||
|
this.setTheme()
|
||||||
|
}
|
||||||
|
|
||||||
|
themeChanged() {
|
||||||
|
this.darkMode = !this.darkMode
|
||||||
|
this.cookieService.set('metube_dark', this.darkMode.toString(), { expires: 3650 });
|
||||||
|
this.setTheme()
|
||||||
|
}
|
||||||
|
|
||||||
|
setTheme() {
|
||||||
|
const doc = document.querySelector('html')
|
||||||
|
const filter = this.darkMode ? "invert(1) hue-rotate(180deg)" : ""
|
||||||
|
doc.style.filter = filter
|
||||||
|
}
|
||||||
|
|
||||||
formatChanged() {
|
formatChanged() {
|
||||||
this.cookieService.set('metube_format', this.format, { expires: 3650 });
|
this.cookieService.set('metube_format', this.format, { expires: 3650 });
|
||||||
// Updates to use qualities available
|
// Updates to use qualities available
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,4 @@
|
||||||
/* You can add global styles to this file, and also import other style files */
|
/* You can add global styles to this file, and also import other style files */
|
||||||
|
|
||||||
@media(prefers-color-scheme: dark)
|
|
||||||
html
|
|
||||||
filter: invert(1) hue-rotate(180deg)
|
|
||||||
|
|
||||||
/* Importing Bootstrap SCSS file. */
|
/* Importing Bootstrap SCSS file. */
|
||||||
@import '~bootstrap/scss/bootstrap'
|
@import '~bootstrap/scss/bootstrap'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue