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

        <ion-buttons slot="end">
          <span v-if="!isInputFocused && false" class="loc-feature-icon calendar">
            <ion-icon class="loc-calendar" name="calendar"></ion-icon>
          </span>
          <span v-if="!isInputFocused && false" class="loc-feature-icon call">
            <ion-icon class="loc-call" name="call"></ion-icon>
          </span>
        </ion-buttons>
      
        <ion-buttons v-if="!isInputFocused && false" slot="start">
          <span class="loc-feature-icon-camera">
            <ion-icon class="loc-camera" name="camera"></ion-icon>
          </span>
        </ion-buttons>

        <div class="loc-textarea-wrapper">
          <ion-textarea 
            class="loc-textarea" :placeholder="placeholder" :rows="isForumBio ? 3 : 1" auto-grow="true" :value="message" 
            v-on:ionFocus="inputFocus()" v-on:ionBlur="inputLosesFocus()" v-on:ionInput="$event => message = $event.target.value">
              <span class="loc-feature-send-icon" @click="sendMessage()">
                <span class="icon icon-messages"></span>
              </span>
          </ion-textarea>
        </div>

      </ion-toolbar>
    </transition>

  </ion-footer>
</template>

<script>
export default {
  props: {
    placeholder: {
      type: String,
      default: "Hi ...",
    },
    isForumBio: {
      type: Boolean,
      default: false,
    }
  },
  data() {
    return {
      message: "",
      isInputFocused: false,
    };
  },
  methods: {
    inputFocus() {
      this.isInputFocused = true;
      this.$emit('inputFocus');
    },
    inputLosesFocus() {
      this.isInputFocused = false;
    },
    sendMessage() {
      this.$emit('sendMessage', this.message);
      this.message = "";
    }
  },
}
</script>

<style scoped lang="css">
  .loc-toolbar {
    min-height: 60px;
    --border-width: 0px !important;
  }
  .loc-feature-icon {
    display: inline-block;
    font-size: 22px;
    line-height: 38px;
    width: 38px;
    text-align: center;
    margin: 9px 0px 9px 6px;
    border-radius: 50%;
    background: #ff5e57;
    color: #fff;
  }
  .loc-feature-icon:active {
    position: relative;
    top: 2px;
  }
  .loc-feature-icon.calendar {
    /* background: #ff5e57; */
    background: var(--ion-color-primary);
  }
  .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;
    bottom: 4px;
    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>