left side drawer is implemented

This commit is contained in:
Richard Park 2020-01-21 18:20:34 +09:00
parent 09e419c917
commit a62a18b0b6
3 changed files with 56 additions and 33 deletions

View File

@ -181,8 +181,6 @@ export class LeftSideComponent implements OnInit, OnDestroy {
if (!!this.badgeMessageInterval) { if (!!this.badgeMessageInterval) {
clearInterval(this.badgeMessageInterval); clearInterval(this.badgeMessageInterval);
} }
this.logger.debug('-----------------------LeftSideComponent ngOnDestroy');
} }
@HostListener('mouseenter', ['$event']) @HostListener('mouseenter', ['$event'])
@ -209,24 +207,25 @@ export class LeftSideComponent implements OnInit, OnDestroy {
@HostListener('mouseleave', ['$event']) @HostListener('mouseleave', ['$event'])
mouseLeave(event: MouseEvent) { mouseLeave(event: MouseEvent) {
const rect = this.leftSideContainer.nativeElement.getBoundingClientRect(); // const rect = this.leftSideContainer.nativeElement.getBoundingClientRect();
// const minX = rect.left;
const minX = rect.left; // const maxX = rect.left + rect.width + 5;
const maxX = rect.left + rect.width + 5; // const minY = rect.top;
const minY = rect.top; // const maxY = rect.top + rect.height;
const maxY = rect.top + rect.height; // if (
// event.pageX >= minX &&
if ( // event.pageX <= maxX &&
event.pageX >= minX && // event.pageY >= minY &&
event.pageX <= maxX && // event.pageY <= maxY
event.pageY >= minY && // ) {
event.pageY <= maxY // } else {
) { // this.store.dispatch(
} else { // ChatStore.toggleLeftSideDrawerIndicator({ show: false })
this.store.dispatch( // );
ChatStore.toggleLeftSideDrawerIndicator({ show: false }) // }
); this.store.dispatch(
} ChatStore.toggleLeftSideDrawerIndicator({ show: false })
);
} }
async onClickNewChat(type: string = 'NORMAL') { async onClickNewChat(type: string = 'NORMAL') {

View File

@ -12,15 +12,6 @@
></app-layout-messenger-left-side> ></app-layout-messenger-left-side>
</mat-drawer> </mat-drawer>
<div class="chat-messages"> <div class="chat-messages">
<button
mat-icon-button
class="left-drawer-toggle"
*ngIf="!showLeftDrawer || showLeftDrawerIndicator"
(click)="onClickLeftDrawerToggle()"
>
<mat-icon>settings</mat-icon>
</button>
<app-layout-messenger-intro <app-layout-messenger-intro
*ngIf="!(this.selectedChat$ | async)" *ngIf="!(this.selectedChat$ | async)"
></app-layout-messenger-intro> ></app-layout-messenger-intro>
@ -32,6 +23,18 @@
(openProfile)="onClickOpenProfile($event)" (openProfile)="onClickOpenProfile($event)"
(closeRightDrawer)="onCloseRightDrawer()" (closeRightDrawer)="onCloseRightDrawer()"
></app-layout-messenger-messages> ></app-layout-messenger-messages>
<button
mat-icon-button
class="left-drawer-toggle"
*ngIf="
!showLeftDrawer || showLeftDrawerIndicator || onLeftDrawerIndicator
"
(click)="onClickLeftDrawerToggle()"
(mouseover)="onMouseOverLeftDrawerIndicator($event)"
(mouseleave)="onMouseLeaveLeftDrawerIndicator($event)"
>
<mat-icon>settings</mat-icon>
</button>
</div> </div>
<mat-drawer <mat-drawer
#rightDrawer #rightDrawer

View File

@ -1,4 +1,4 @@
import { map, tap, take, catchError } from 'rxjs/operators'; import { map, tap, take, catchError, debounce } from 'rxjs/operators';
import { import {
Component, Component,
OnInit, OnInit,
@ -14,7 +14,7 @@ import * as AppStore from '@app/store';
import * as ChatStore from '@app/store/messenger/chat'; import * as ChatStore from '@app/store/messenger/chat';
import * as MessageStore from '@app/store/messenger/message'; import * as MessageStore from '@app/store/messenger/message';
import * as StatusStore from '@app/store/messenger/status'; import * as StatusStore from '@app/store/messenger/status';
import { Observable, Subscription, of } from 'rxjs'; import { Observable, Subscription, of, timer, EMPTY } from 'rxjs';
import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native'; import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native';
import { StatusProtocolService } from '@ucap-webmessenger/protocol-status'; import { StatusProtocolService } from '@ucap-webmessenger/protocol-status';
@ -76,6 +76,7 @@ export class MainPageComponent implements OnInit, OnDestroy {
showLeftDrawer = true; showLeftDrawer = true;
showLeftDrawerIndicator = false; showLeftDrawerIndicator = false;
onLeftDrawerIndicator = false;
constructor( constructor(
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService, @Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
@ -121,11 +122,16 @@ export class MainPageComponent implements OnInit, OnDestroy {
select(AppStore.MessengerSelector.ChatSelector.selectLeftSideDrawer) select(AppStore.MessengerSelector.ChatSelector.selectLeftSideDrawer)
) )
.subscribe(leftSideDrawer => { .subscribe(leftSideDrawer => {
this.showLeftDrawer = leftSideDrawer;
if (leftSideDrawer) { if (leftSideDrawer) {
this.leftSideDrawer.open(); this.leftSideDrawer.open().then(() => {
this.showLeftDrawer = true;
});
} else { } else {
this.showLeftDrawer = false;
this.leftSideDrawer.close(); this.leftSideDrawer.close();
this.store.dispatch(
ChatStore.toggleLeftSideDrawerIndicator({ show: false })
);
} }
}); });
@ -133,6 +139,9 @@ export class MainPageComponent implements OnInit, OnDestroy {
.pipe( .pipe(
select( select(
AppStore.MessengerSelector.ChatSelector.selectLeftSideDrawerIndicator AppStore.MessengerSelector.ChatSelector.selectLeftSideDrawerIndicator
),
debounce(leftSideDrawerIndicator =>
leftSideDrawerIndicator ? EMPTY : timer(500)
) )
) )
.subscribe(leftSideDrawerIndicator => { .subscribe(leftSideDrawerIndicator => {
@ -434,4 +443,16 @@ export class MainPageComponent implements OnInit, OnDestroy {
onClickLeftDrawerToggle() { onClickLeftDrawerToggle() {
this.store.dispatch(ChatStore.toggleLeftSideDrawer()); this.store.dispatch(ChatStore.toggleLeftSideDrawer());
} }
onMouseOverLeftDrawerIndicator(event: MouseEvent) {
if (!this.onLeftDrawerIndicator) {
this.onLeftDrawerIndicator = true;
}
}
onMouseLeaveLeftDrawerIndicator(event: MouseEvent) {
if (this.onLeftDrawerIndicator) {
this.onLeftDrawerIndicator = false;
}
}
} }