<script setup>
import { ref, onMounted } from "vue";
const isIos = ref(true);

const props = defineProps({
  title: {
    type: String,
    default: "",
  },
  onBack: {
    type: Function,
    default: null,
  },
});

const onClick = () => {
  if (props.onBack) props.onBack();
  else uni.navigateBack();
};

onMounted(() => {
  const deviceInfo = uni.getDeviceInfo();
  isIos.value = deviceInfo.osName === "ios";
});
</script>

<template>
  <view class="container" :style="{ paddingTop: isIos ? '38px' : '25px' }">
    <view class="back-btn" @click="onClick">
      <image src="../static/back.png" mode="widthFix" />
    </view>
    <text>{{ title }}</text>
  </view>
</template>

<style scoped>
.container {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  width: 72vw;
  height: 60px;
  /* margin-top: var(--status-bar-height); */
  padding-left: 15px;
}
.back-btn {
  display: flex;
  align-items: center;
}
.back-btn > image {
  width: 22px;
  height: 22px;
  margin-right: 10px;
}
.container > text {
  color: #fff;
}
</style>
