import {FC} from "react";
import {View} from "@tarojs/components";
import styles from "./home.module.scss";
import Taro from "@tarojs/taro";
import {Search} from "@/pages/home/components/search";
import Adware from "@/pages/home/components/adware";
import Feature from "@/pages/home/components/feature";
import FeatureRecommended from "@/pages/home/components/feature_recommended";
import CurRecommended from "@/pages/home/components/curRecommended";
import MyButton from "@/components/button/MyButton";
import {Profile} from "@/store";

const Home: FC = () => {
  const menu = Taro.getMenuButtonBoundingClientRect()
  const {token, empty} = Profile.useContainer()
  const headerStyle: React.CSSProperties = {
    height: `${menu.bottom}px`,
  }

  return (
    <View className={styles.content} style={`paddingTop:${menu.bottom}px`}>
      <View className={styles.header} style={headerStyle}>康一诺</View>
      <Search/>
      <Adware/>
      <Feature/>
      <FeatureRecommended/>
      <CurRecommended/>
      {
        !token && <View className={styles.tipsLogin} onClick={empty}>
          <View>登录后享受更多学习服务~</View>
          <MyButton fillet size='mini'>立即登录</MyButton>
        </View>
      }
    </View>
  )
}

export default Home
