package com.iscs.bozzys.ui.base

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel

/**
 * 全局Loading弹窗
 */
@Composable
fun LoadingCompose(vm: VMLoading = viewModel()) {
    if (!vm.state.show) return
    Box(
        Modifier
            .fillMaxSize()
            .pointerInput(Unit) {}, // 不允许点击穿透
        contentAlignment = Alignment.Center
    ) {
        Box(
            Modifier
                .sizeIn(80.dp, 80.dp, 300.dp, 300.dp)
                .clip(RoundedCornerShape(20.dp))
                .background(Color.Black.copy(alpha = 0.5f)),
            contentAlignment = Alignment.Center

        ) {
            CircularProgressIndicator()
        }

    }
}