Add Settings Popup

This commit is contained in:
copecone committed 2026-03-26 00:14:43 +09:00
1 parent d946ee4026
commit 010771b22a
15 files changed
+335 -50

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
import { Injectable, signal, Type } from '@angular/core';
@Injectable({
providedIn: 'root',
})
export class PopupService {
/**
* 현재 활성화된 팝업 컴포넌트들의 리스트 (Signal)
*/
activePopups = signal<Type<any>[]>([]);
/**
* 팝업을 엽니다. 이미 열려있는 동일한 컴포넌트가 있다면 중복해서 열지 않습니다.
*/
open<T>(component: Type<T>) {
this.activePopups.update((popups) => {
if (popups.includes(component)) return popups;
return [...popups, component];
});
}
/**
* 특정 컴포넌트를 닫습니다.
*/
close(component: Type<any>) {
this.activePopups.update((popups) => popups.filter((p) => p !== component));
}
/**
* 가장 최근에 열린(마지막) 팝업을 닫습니다.
*/
closeLast() {
this.activePopups.update((popups) => popups.slice(0, -1));
}
/**
* 모든 팝업을 닫습니다.
*/
closeAll() {
this.activePopups.set([]);
}
}