<template>
  <ion-content padding>
  	<h1>Modal</h1>
  	<p>A Modal is a dialog that appears on top of the app's content, and must be dismissed by the app before interaction can resume. It is useful as a select component when there are a lot of options to choose from, or when filtering items in a list, as well as many other use cases. <a href="https://ionicframework.com/docs/api/modal">See full documentation.</a></p>
    <h1>Demo</h1>
    <ion-button @click="openModalWithPadding">Open Modal With Padding</ion-button>
    <ion-button @click="openModalWithoutPadding">Open Modal Without Padding</ion-button>
    <ion-button @click="openIntroductionModal">Open Introduction Modal</ion-button>
    <ion-button @click="openAnnouncementModal">Open Announcement Modal</ion-button>
    <ion-button @click="openRecoFeedbackModal">Open Feedback Modal</ion-button>
    <ion-button @click="openRecoRapidPostModal">Open On the Spot Modal</ion-button>
  </ion-content>
</template>

<script>
import ModalWithPadding from '@/components/examples/ModalWithPadding.vue'
import ModalWithoutPadding from '@/components/examples/ModalWithoutPadding.vue'
import IntroModal from '@/components/complex/RecoIntroduction.vue'
import TopPic from '@/assets/actiways_logo.png'
import BottomPic from '@/assets/opening.png'
import Posts from '@/assets/posts.png'
import Follows from '@/assets/follows.png'
import Chat from '@/assets/chat.png'
import AnnouncementModal from '@/components/complex/RecoAnnouncement.vue'
import RecoFeedback from '@/components/complex/RecoFeedback.vue'
import RecoRapidPost from '@/components/complex/RecoRapidPost.vue'


export default {
  methods: {
    openModalWithPadding() {
      return this.$ionic.modalController
        .create({
          component: ModalWithPadding,
          componentProps: {
            propsData: {
              title: 'Modal With Padding',
            },
          },
        })
        .then(m => m.present())
    },
    openModalWithoutPadding() {
      return this.$ionic.modalController
        .create({
          component: ModalWithoutPadding,
          componentProps: {
            propsData: {
              title: 'Modal Without Padding',
            },
          },
        })
        .then(m => m.present())
    },
  openIntroductionModal(){
    return this.$ionic.modalController.create({
        component: IntroModal,
        componentProps: {
          propsData:{
            slides:[
              {
                upperImg: TopPic, 
                text: 'Welcome to Actiways! Let us show you around.', 
                lowerImg: BottomPic
              },
              {
                upperImg: TopPic, 
                text: 'On this tab you can see the posts around you. You can filter this feed to be more specific to your interests!', 
                lowerImg: Posts
              },
              {
                upperImg: TopPic, 
                text: "Here you will see the posts of users you're following.", 
                lowerImg: Follows
              },
              {
                upperImg: TopPic,
                text: 'This is the chat. You can chat in private or groups or even forums as large as 10000 people!', 
                lowerImg: Chat
              },
              {
                upperImg: TopPic,
                text: 'You can use this button to create your own posts for others to see and reply to.', 
                lowerImg: BottomPic
              }
            ],
            finalSlideTopPic: TopPic,
            closeIntroduction: () =>{
              if(this.IntroductionModal){
                this.IntroductionModal.dismiss();
              }
            }
          }
        }
      }).then(i => {
        this.IntroductionModal = i;
        i.present();
      });
    },
    openAnnouncementModal(){
      this.$ionic.modalController.create({
        component: AnnouncementModal,
        componentProps: {
          propsData:{
            AnnouncementTitle: "This is the title",
            AnnouncementBody: 'And this is the long text under the title, in which we explain or announce something important to our users. <br/> <br/> Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.',
            closeAnnouncement: () =>{
              if(this.AnnouncementModal){
                this.AnnouncementModal.dismiss();
              }
            }
          }
        }
      }).then(a => {
        this.AnnouncementModal = a; 
        a.present();
      });
    },
    openRecoFeedbackModal(){
      this.$ionic.modalController.create({
        component: RecoFeedback,
        componentProps:{
          propsData:{
            backButtonClicked: () => { 
              if(this.RecoFeedback) this.RecoFeedback.dismiss();
            },
            doneButtonClicked: (event) => {
              console.log('Submit clicked', event);
              this.RecoFeedback.dismiss();
            }
          }
        }
      }).then(f =>{
        this.RecoFeedback = f;
        f.present();
      });
    },
    openRecoRapidPostModal(){
      this.$ionic.modalController.create({
        component: RecoRapidPost,
        componentProps:{
          propsData:{
            backButtonClicked: () => { 
                if(this.RecoRapidPost) this.RecoRapidPost.dismiss();
            },
            me: {uid: 1, languages: { post_language: 'en', spoken_languages: ['hu', 'en', 'aa']}},
            submitPost: (post) => { console.log('submitted post:', post);}
          }
        }
      }).then(r => {
        this.RecoRapidPost = r;
        r.present();
      });
    }
  },
  data(){
    return {
      IntroductionModal: null
    }
  }
}
</script>