package com.lanyun.wanglaotou.public

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
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.unit.sp
import com.google.accompanist.insets.navigationBarsHeight
import com.google.accompanist.insets.navigationBarsPadding
import com.google.accompanist.insets.statusBarsHeight

/**
 * 在不想使用透明状态栏/导航栏的时候
 * 用这个作为基础的布局可以让内容不被状态栏/导航栏遮挡
 */
@Composable
fun BaseScreen(content: @Composable () -> Unit) {

    Column(
        modifier = Modifier.fillMaxSize()
    ) {

        //内容不挡住状态栏 如果不设置颜色这里会自己适配，但可能产生闪烁
        Spacer(modifier = Modifier.background(MaterialTheme.colors.primary).statusBarsHeight().fillMaxWidth())

        content()

        //内容不挡住导航栏 如果不设置颜色这里会自己适配，但可能产生闪烁
        Spacer(modifier = Modifier.background(MaterialTheme.colors.primary).navigationBarsHeight().fillMaxWidth())

    }

}

//上下布局
@Composable
fun ColumnScreen(modifier: Modifier = Modifier,content: @Composable () -> Unit) {
    Row(
        modifier = Modifier.background(MaterialTheme.colors.background).then(modifier),
        verticalAlignment = Alignment.CenterVertically
    ) {

        Column(
            modifier = Modifier.weight(1f, true)
        ) {
            content()
        }

    }
}