<template>
  <ion-footer>
    <transition name="custom-classes-transition" enter-active-class="animated bounceInLeft">
      <ion-toolbar class="loc-toolbar">

        <ion-buttons slot="start">
          <span class="add-icon-box settings" @click="openRecoForumSettingsModal">
            <ion-icon class="add-icon" name="settings"></ion-icon>
          </span>
        </ion-buttons>

        <ion-buttons slot="end">
          <span class="add-icon-box" @click="isForumPostComposerModalOpen = true">
            <ion-icon class="add-icon" name="add"></ion-icon>
          </span>
        </ion-buttons>

      </ion-toolbar>
    </transition>

    <reco-forum-post-composer-modal
      v-if="isForumPostComposerModalOpen"
      title="Create Forum Post"
      :root="this"
      :me="me"
      :submitForumPost="submitForumPost"
    />

  </ion-footer>
</template>

<script>
import RecoForumPostComposerModal from '@/components/complex/RecoForumPostComposerModal.vue';
import RecoForumSettingsModal from '@/components/complex/RecoForumSettingsModal.vue';

export default {
  components: {
    RecoForumPostComposerModal, RecoForumSettingsModal
  },
  props: {
    me: {
      type: Object,
    },
    placeholder: {
      type: String,
      default: "Hi ..."
    },
    chat: {
      type: Object,
      default() {
        return null;
      },
    },
    isMeOwner: {
      type: Boolean,
      default: false,
    },
    isMeAdmin: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      isInputFocused: false,
      isForumPostComposerModalOpen: false,
      recoForumSettingsModal: false,
    };
  },
  methods: {
    inputFocus() {
      this.isInputFocused = true;
    },
    inputLosesFocus() {
      this.isInputFocused = false;
    },
    submitForumPost(post) {
      this.$emit('sendForumPost', post);
    },
    openRecoForumSettingsModal() {
      const self = this;
      return self.$ionic.modalController.create({
        component: RecoForumSettingsModal,
        componentProps: {
          propsData: {
            me: this.me,
            chat: this.chat,
            isMeOwner: this.isMeOwner,
            isMeAdmin: this.isMeAdmin,
          },
          methods: {
            deleteForum(data) {
              self.$emit('deleteForum', data);
            },
            deleteUser(data) {
              self.$emit('deleteUser', data);
            },
            exitForum() {
              self.$emit('exitForum');
            },
            reportForum() {
              self.$emit('reportForum');
            },
            openUserProfile(user) {
              self.$emit('openUserProfile', user);
            },
            backButtonClicked() {
              self.recoForumSettingsModal.dismiss();
            }
          },
        },
      })
      .then(m => {
        self.recoForumSettingsModal = m;
        self.recoForumSettingsModal.present();
      })
    }
  },
}
</script>

<style scoped lang="css">
  .loc-toolbar {
    min-height: 60px;
    --border-width: 0px !important;
  }
  .loc-feature-icon:active {
    position: relative;
    top: 2px;
  }
  .add-icon-box {
    /* background: #ff5e57; */
    border: 2px solid #333;
    color: #333;
    width: 42px;
    height: 42px;
    border-radius: 21px;
    text-align: center;
    line-height: 44px;
    font-size: 28px;
    margin: 5px 10px;
  }
  .add-icon-box.settings {
    position: relative;
    top: 3px;
    border: none;
  }
  .loc-feature-icon.call {
    /* background: #05c46b; */
    background: var(--ion-color-primary);
    margin-right: 8px;
  }
  .loc-feature-icon-camera {
    display: inline-block;
    font-size: 30px;
    color: var(--ion-color-primary);
    margin-left: 8px;
    margin-right: 6px;
  }
  .loc-feature-icon-camera:active {
    position: relative;
    top: 2px;
  }
  .loc-feature-send-icon {
    display: block;
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 22px;
  }
  .loc-feature-send-icon:active {
    bottom: -7px;
  }
  .loc-camera,
  .loc-calendar,
  .loc-call {
    position: relative;
  }
  .loc-camera {
    top: 2px;
  }
  .loc-calendar {
    top: 2px;
  }
  .loc-call {
    top: 3px;
  }
  .loc-input {
    line-height: 38px;
    border-radius: 19px;
    background: var(--ion-color-light);
    border: 1px solid #ddd;
    --padding-top: 0px;
    --padding-end: 8px;
    --padding-bottom: 0px;
    --padding-start: 8px;
  }
  .loc-textarea {
    position: relative;
    margin: 9px 0px 9px 0px;
    border-radius: 19px;
    background: var(--ion-color-light);
    border: 1px solid #ddd;
    --padding-top: 10px;
    --padding-end: 50px;
    --padding-bottom: 9px;
    --padding-start: 15px;
    display: block; 
    min-height: 40px !important;
  } 
</style>