package com.lanyun.wanglaotou.public

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*

import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.navigation.NavHostController
import com.lanyun.wanglaotou.KeyNavigationRoute
import com.lanyun.wanglaotou.R

/**
 * 无数据时候的布局
 */
@Composable
fun ErrorComposable(title: String = "网络不佳，请点击重试", block: () -> Unit) {

    Column(
        modifier = Modifier.background(MaterialTheme.colors.background).fillMaxSize(),
        verticalArrangement = Arrangement.Center,
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        Image(
            modifier = Modifier.size(300.dp, 180.dp),
            painter = painterResource(id = R.drawable.baseline_wifi_24),
            contentDescription = "网络问题",
            contentScale = ContentScale.Crop
        )

        Button(modifier = Modifier.padding(8.dp), onClick = block) {
            Text(title)
        }
    }

}


@Composable
fun NoLogin(
    navHostController: NavHostController
){
    Column(
        verticalArrangement = Arrangement.Center,
        horizontalAlignment= Alignment.CenterHorizontally,
        modifier = Modifier
            .clickable(
                onClick = {
                    //跳转到登录页面
                    navHostController.navigate(KeyNavigationRoute.LOGIN.route)
                }
            )
            .background(MaterialTheme.colors.background)
            .fillMaxSize()
    ){
        Text(text = "需要登录登录")
    }
}
