import {Component, OnInit } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';

import { environment } from "../../environments/environment"
import {SocialSharing} from "@ionic-native/social-sharing";
import {NewsService} from "../../services/news.service";
import * as moment from 'moment';
@Component({
  selector: 'page-newsDetalle',
  templateUrl: 'newsDetalle.html'
})
export class NewsDetalle implements OnInit{


  public staticUrl: string;
  public image = '';
  public link = '';
  news: any = null;
  private isSharing: boolean;


  constructor(public navCtrl: NavController,
              private navParams: NavParams,
              private socialSharing: SocialSharing,
              private newsService: NewsService)
  {
    this.staticUrl = environment.staticUrl;
    this.news = this.navParams.get("news");
  }

  ngOnInit(){
    /*
    this.newsService.getFeatured(this.news.featured_media).subscribe(
      (data: any) => {
        this.image =  data.guid.rendered;
      },
      error => {
        console.log(error);
      }
    )
    */
  }


  share(){
    /*
    if(this.isSharing) return false;
    this.isSharing = true;
    this.socialSharing.share(this.news.title.rendered,this.news.description, this.image, this.news.link).then(() => {
      this.isSharing = false;
    }).catch(() => {
      this.isSharing = false;
    });
    */
  }
  dateformat(fecha){
    var fecha_mm = moment(fecha);
    return moment(fecha_mm.format(),moment.ISO_8601).format();
  }

}
