import { Component, OnInit, Inject, OnDestroy } from '@angular/core';
import {
  UCAP_NATIVE_SERVICE,
  NativeService,
  WindowState
} from '@ucap-webmessenger/native';
import { Observable } from 'rxjs';

@Component({
  selector: 'app-layout-native-top-bar',
  templateUrl: './top-bar.component.html',
  styleUrls: ['./top-bar.component.scss']
})
export class TopBarComponent implements OnInit, OnDestroy {
  windowStateChanged$: Observable<WindowState>;

  WindowState = WindowState;

  constructor(
    @Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService
  ) {}

  ngOnInit() {
    this.windowStateChanged$ = this.nativeService.windowStateChanged();
  }

  ngOnDestroy(): void {}

  onClickClose() {
    this.nativeService.windowClose();
  }

  onClickMinimize() {
    this.nativeService.windowMinimize();
  }

  onClickMaxmize() {
    this.nativeService.windowMaximize();
  }
}
