package com.zaojiao.app.feat.home.personal

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color

/**
 *  首页 - 我的勋章
 */
@Composable
fun HomePersonalPage() {
    Box(
        modifier = Modifier
            .background(
                brush = Brush.verticalGradient(
                    listOf(Color(0xFFFEFEFE), Color(0xFFFAFAFA)),
                )
            )
            .fillMaxSize()
    ) {
        val state = rememberLazyListState()

        LazyColumn(
            state = state
        ) {
            item {
                HomePersonalTopBar()
            }

            item {
                HomePersonalUserBar()
            }

            item {
                HomePersonalEngage()
            }

            item {
                HomePersonalContent()
            }

            item {
                HomePersonalAccount()
            }

            item {
                HomePersonalService()
            }

            item {
                HomePersonalBottom()
            }
        }

        val showTop by remember {
            derivedStateOf {
                state.firstVisibleItemIndex > 1
            }
        }

        AnimatedVisibility(
            visible = showTop,
            enter = fadeIn(),
            exit = fadeOut(),
        ) {
            HomePersonalScrollTopBar()
        }
    }
}


