import { Component, OnInit, Input } 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: 'scroll-content',
  templateUrl: './scroll-content.component.html',
  styleUrls: ['./scroll-content.component.scss'],
})
export class ScrollContentComponent implements OnInit {


  public keyboardOpened = false;
  @Input() fullView = 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;
    });
  }

}
