import { Component, OnInit } from '@angular/core';
import { KeyboardService } from '../../services/keyboard/keyboard.service';
import { Events, Platform } from '@ionic/angular';
import { KeyboardStatusModel } from '../../services/keyboard/keyboard-status.model';

@Component({
  selector: 'footer',
  templateUrl: './footer.component.html',
  styleUrls: ['./footer.component.scss'],
})
export class FooterComponent implements OnInit {

  public keyboardOpened = false;
  constructor(
    public events: Events,
    public keyboardService: KeyboardService,
    public platform: Platform
  ) { }

  
  ngOnInit() {
    this.platform.ready().then(() => {
      this.keyboardOpened = KeyboardService.keyboardOpened;
      this.monitorKeyboardChange();
    });
  }

  private monitorKeyboardChange() {
    this.events.subscribe (  KeyboardService.KEYBOARD_STATUS , ( status: KeyboardStatusModel) => {
      this.keyboardOpened = status.opened;
    });
  }

}
