You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.9 KiB
92 lines
2.9 KiB
package com.gyf.lib.uikit
|
|
|
|
import androidx.compose.foundation.Image
|
|
import androidx.compose.foundation.border
|
|
import androidx.compose.foundation.layout.*
|
|
import androidx.compose.material.Card
|
|
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.unit.dp
|
|
import com.google.accompanist.coil.rememberCoilPainter
|
|
import com.gyf.lib.util.*
|
|
|
|
|
|
@Composable
|
|
fun Profile(
|
|
modifier: Modifier,
|
|
personInfoVo: PersonInfoVo = TokenManager.getOwnInfo(),
|
|
duty: @Composable () -> Unit = {
|
|
Text(
|
|
text = when (personInfoVo) {
|
|
is UserVo -> personInfoVo.manager?.duty?.desc ?: "----"
|
|
is ManagerVo -> personInfoVo.duty.desc
|
|
is ManagerInfoVo -> personInfoVo.duty.desc
|
|
else -> throw IllegalArgumentException("个人信息类型错误:${personInfoVo}")
|
|
}
|
|
)
|
|
}
|
|
) {
|
|
|
|
Column(
|
|
modifier = modifier,
|
|
) {
|
|
Row(
|
|
modifier = Modifier
|
|
.fillMaxWidth()
|
|
.weight(0.7F)
|
|
.border(width = 1.dp, color = MaterialTheme.colors.onBackground),
|
|
horizontalArrangement = Arrangement.SpaceBetween
|
|
) {
|
|
|
|
personInfoVo.headImg.let {
|
|
if (it != null) {
|
|
val headImg = rememberCoilPainter(request = Api.buildUrl(it))
|
|
Image(
|
|
painter = headImg,
|
|
contentDescription = null,
|
|
modifier = Modifier
|
|
.weight(0.4F)
|
|
.fillMaxHeight()
|
|
)
|
|
} else {
|
|
Box(
|
|
modifier = Modifier
|
|
.weight(0.4F)
|
|
.fillMaxHeight(),
|
|
contentAlignment = Alignment.Center
|
|
) {
|
|
Text(text = "没有头像")
|
|
}
|
|
}
|
|
}
|
|
Column(
|
|
modifier = Modifier
|
|
.weight(0.4F)
|
|
.fillMaxHeight()
|
|
.border(width = 1.dp, color = MaterialTheme.colors.onBackground),
|
|
verticalArrangement = Arrangement.SpaceEvenly,
|
|
horizontalAlignment = Alignment.CenterHorizontally
|
|
) {
|
|
Text(text = personInfoVo.name)
|
|
duty()
|
|
}
|
|
}
|
|
|
|
Spacer(modifier = Modifier.weight(0.05F))
|
|
|
|
Card(
|
|
backgroundColor = MaterialTheme.colors.background,
|
|
modifier = Modifier.weight(0.15F)
|
|
) {
|
|
Row(
|
|
modifier = Modifier.fillMaxWidth(),
|
|
horizontalArrangement = Arrangement.Center
|
|
) {
|
|
Text(text = personInfoVo.desc)
|
|
}
|
|
}
|
|
}
|
|
} |