added draggable aspect in service

This commit is contained in:
Nicolas Constant 2023-08-20 01:44:46 -04:00
parent 335cbf4956
commit f215d027f9
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
3 changed files with 20 additions and 7 deletions

View File

@ -8,15 +8,15 @@
<fa-icon [icon]="faSearch"></fa-icon>
</a>
<div *ngFor="let account of accounts">
<app-account-icon [account]="account" (toogleAccountNotify)="onToogleAccountNotify($event)"
(openMenuNotify)="onOpenMenuNotify($event)">
</app-account-icon>
<div *ngIf="!iconMenuIsDraggable">
<div *ngFor="let account of accounts">
<app-account-icon [account]="account" (toogleAccountNotify)="onToogleAccountNotify($event)"
(openMenuNotify)="onOpenMenuNotify($event)">
</app-account-icon>
</div>
</div>
<div cdkDropList
[cdkDropListData]="accounts"
(cdkDropListDropped)="onDrop($event)">
<div *ngIf="iconMenuIsDraggable" cdkDropList [cdkDropListData]="accounts" (cdkDropListDropped)="onDrop($event)">
<div *ngFor="let account of accounts" cdkDrag class="draggable">
<fa-icon class="draggable__icon" [icon]="faArrowsAltV"></fa-icon>
<img class="draggable__avatar" src="{{ account.avatar }}" />

View File

@ -35,6 +35,7 @@ export class LeftSideBarComponent implements OnInit, OnDestroy {
private accountSub: Subscription;
private scheduledSub: Subscription;
private notificationSub: Subscription;
private draggableIconMenuSub: Subscription;
constructor(
private readonly settingsService: SettingsService,
@ -105,7 +106,13 @@ export class LeftSideBarComponent implements OnInit, OnDestroy {
}
}
iconMenuIsDraggable = false;
ngOnInit() {
this.draggableIconMenuSub = this.navigationService.enableDraggableIconMenu.subscribe(x => {
this.iconMenuIsDraggable = x;
});
this.accountSub = this.accounts$.subscribe((accounts: AccountInfo[]) => {
if (accounts) {
//Update and Add
@ -166,6 +173,7 @@ export class LeftSideBarComponent implements OnInit, OnDestroy {
this.accountSub.unsubscribe();
this.notificationSub.unsubscribe();
this.scheduledSub.unsubscribe();
this.draggableIconMenuSub.unsubscribe();
}
onDrop(event: CdkDragDrop<AccountWithNotificationWrapper[]>) {

View File

@ -10,6 +10,7 @@ export class NavigationService {
activatedPanelSubject = new BehaviorSubject<OpenLeftPanelEvent>(new OpenLeftPanelEvent(LeftPanelType.Closed));
activatedMediaSubject: Subject<OpenMediaEvent> = new Subject<OpenMediaEvent>();
columnSelectedSubject = new BehaviorSubject<number>(-1);
enableDraggableIconMenu = new BehaviorSubject<boolean>(false);
constructor() { }
@ -19,6 +20,10 @@ export class NavigationService {
this.activatedPanelSubject.next(newEvent);
}
changeIconMenuState(draggable: boolean) {
this.enableDraggableIconMenu.next(draggable);
}
openPanel(type: LeftPanelType){
const newEvent = new OpenLeftPanelEvent(type);
this.activatedPanelSubject.next(newEvent);