@@ -61,7 +61,8 @@ import com.aiosman.ravenow.ui.composables.form.FormTextInput2
|
||||
import com.aiosman.ravenow.ui.modifiers.noRippleClickable
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.ui.draw.shadow
|
||||
/**
|
||||
* 添加智能体界面
|
||||
*/
|
||||
@@ -73,7 +74,7 @@ fun AddAgentScreen() {
|
||||
var agnetNameError by remember { mutableStateOf<String?>(null) }
|
||||
var agnetDescError by remember { mutableStateOf<String?>(null) }
|
||||
var errorMessage by remember { mutableStateOf<String?>(null) }
|
||||
|
||||
var isProcessing by remember { mutableStateOf(false) }
|
||||
|
||||
|
||||
fun onNameChange(value: String) {
|
||||
@@ -148,88 +149,150 @@ fun AddAgentScreen() {
|
||||
stringResource(R.string.agent_add),
|
||||
fontWeight = FontWeight.W600,
|
||||
modifier = Modifier.weight(1f),
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 17.sp,
|
||||
color = appColors.text
|
||||
)
|
||||
Spacer(modifier = Modifier.size(12.dp))
|
||||
Icon(
|
||||
modifier = Modifier
|
||||
.size(24.dp)
|
||||
.noRippleClickable {
|
||||
// 提交创建智能体的逻辑可以在这里实现
|
||||
},
|
||||
imageVector = Icons.Default.Check,
|
||||
contentDescription = "Add",
|
||||
tint = appColors.text
|
||||
)
|
||||
}
|
||||
}
|
||||
Spacer(modifier = Modifier.height(44.dp))
|
||||
Box(
|
||||
modifier = Modifier.size(88.dp),
|
||||
contentAlignment = Alignment.Center
|
||||
Spacer(modifier = Modifier.height(32.dp))
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(113.dp)
|
||||
.padding(horizontal = 20.dp),
|
||||
) {
|
||||
CustomAsyncImage(
|
||||
context,
|
||||
model.croppedBitmap,
|
||||
modifier = Modifier
|
||||
.size(88.dp)
|
||||
.size(48.dp)
|
||||
.clip(
|
||||
RoundedCornerShape(88.dp)
|
||||
RoundedCornerShape(48.dp)
|
||||
),
|
||||
contentDescription = "",
|
||||
contentScale = ContentScale.Crop,
|
||||
placeholderRes = R.mipmap.rider_pro_agent_avatar
|
||||
placeholderRes = R.mipmap.group_copy
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Text(
|
||||
text = "Aoisan 你好呀!今天想创造什么?",
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.clip(CircleShape)
|
||||
.background(appColors.main)
|
||||
.align(Alignment.BottomEnd)
|
||||
.noRippleClickable {
|
||||
// 设置正在选择头像的标志
|
||||
model.isSelectingAvatar = true
|
||||
navController.navigate(NavigationRoute.AgentImageCrop.route)
|
||||
},
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.Add,
|
||||
contentDescription = "Add",
|
||||
tint = Color.White,
|
||||
)
|
||||
}
|
||||
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.W600
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Text(
|
||||
text = "只需要一句话,你的专属AI将在这里诞生.",
|
||||
fontSize = 14.sp
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(58.dp))
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 16.dp)
|
||||
.padding(horizontal = 20.dp)
|
||||
) {
|
||||
FormTextInput(
|
||||
value = model.name,
|
||||
label = stringResource(R.string.agent_name),
|
||||
hint = stringResource(R.string.agent_name_hint),
|
||||
background = appColors.inputBackground2,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) { value ->
|
||||
onNameChange(value)
|
||||
}
|
||||
// Spacer(modifier = Modifier.height(16.dp))
|
||||
FormTextInput2(
|
||||
value = model.desc,
|
||||
label = stringResource(R.string.agent_desc),
|
||||
hint = stringResource(R.string.agent_desc_hint),
|
||||
background = appColors.inputBackground2,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) { value ->
|
||||
onDescChange(value)
|
||||
Box {
|
||||
FormTextInput2(
|
||||
value = model.desc,
|
||||
hint = "一个会写诗的AI,一个懂你笑点的AI...",
|
||||
background = appColors.inputBackground2,
|
||||
modifier = Modifier.fillMaxWidth().height(95.dp)
|
||||
// 阴影效果
|
||||
.shadow(
|
||||
elevation = 10.dp,
|
||||
shape = RoundedCornerShape(10.dp),
|
||||
spotColor = Color(0x33F563FF),
|
||||
ambientColor = Color(0x99F563FF),
|
||||
clip = false
|
||||
)
|
||||
.background(
|
||||
brush = Brush.linearGradient(
|
||||
listOf(
|
||||
Color(0xFF6246FF),
|
||||
Color(0xFF7C45ED)
|
||||
)
|
||||
),
|
||||
shape = RoundedCornerShape(10.dp)
|
||||
)
|
||||
.padding(0.5.dp)
|
||||
.background(
|
||||
color = appColors.inputBackground2,
|
||||
shape = RoundedCornerShape(10.dp)
|
||||
)
|
||||
) { value ->
|
||||
onDescChange(value)
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.align(Alignment.BottomEnd)
|
||||
.padding(end = 12.dp, bottom = 12.dp)
|
||||
.noRippleClickable {
|
||||
if (!isProcessing && model.desc.isNotEmpty()) {
|
||||
isProcessing = true
|
||||
model.viewModelScope.launch {
|
||||
try {
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
isProcessing = false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.mipmap.icons_info_magic),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp),
|
||||
tint = Color.Unspecified
|
||||
)
|
||||
Spacer(modifier = Modifier.width(5.dp))
|
||||
Text(
|
||||
text = "AI美化",
|
||||
color = Color(0xFF6246FF),
|
||||
fontSize = 14.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Spacer(modifier = Modifier.height(58.dp))
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(start = 20.dp, top = 24.dp,end = 213.dp)
|
||||
.width(126.dp)
|
||||
.height(40.dp)
|
||||
.border(
|
||||
width = 1.dp,
|
||||
color = Color(0x33858B98),
|
||||
shape = RoundedCornerShape(12.dp)
|
||||
)
|
||||
.background(
|
||||
color = appColors.background,
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(horizontal = 16.dp, vertical = 10.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.mipmap.icons_infor_edit),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp),
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(
|
||||
text = "手动创造Ai",
|
||||
color = Color.Black,
|
||||
fontWeight = FontWeight.W600,
|
||||
fontSize = 14.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
Spacer(modifier = Modifier.height(280.dp))
|
||||
|
||||
// 错误信息显示
|
||||
errorMessage?.let { error ->
|
||||
@@ -249,18 +312,17 @@ fun AddAgentScreen() {
|
||||
.background(
|
||||
brush = Brush.linearGradient(
|
||||
colors = listOf(
|
||||
Color(0xFFEE2A33),
|
||||
Color(0xFFD80264),
|
||||
Color(0xFF8468BC)
|
||||
Color(0x777c45ed),
|
||||
Color(0x777c68ef),
|
||||
Color(0x557bd8f8)
|
||||
)
|
||||
),
|
||||
shape = RoundedCornerShape(24.dp)
|
||||
),
|
||||
color = Color.White,
|
||||
backgroundColor = Color.Transparent,
|
||||
text = stringResource(R.string.agent_create),
|
||||
text = stringResource(R.string.create_confirm),
|
||||
isLoading = model.isUpdating,
|
||||
loadingText = stringResource(R.string.agent_createing),
|
||||
enabled = !model.isUpdating && validate()
|
||||
) {
|
||||
// 验证输入
|
||||
|
||||
@@ -66,9 +66,9 @@ object AddAgentViewModel : ViewModel() {
|
||||
|
||||
fun validate(): String? {
|
||||
return when {
|
||||
name.isEmpty() -> "智能体名称不能为空"
|
||||
name.length < 2 -> "智能体名称长度不能少于2个字符"
|
||||
name.length > 20 -> "智能体名称长度不能超过20个字符"
|
||||
// name.isEmpty() -> "智能体名称不能为空"
|
||||
// name.length < 2 -> "智能体名称长度不能少于2个字符"
|
||||
// name.length > 20 -> "智能体名称长度不能超过20个字符"
|
||||
desc.isEmpty() -> "智能体描述不能为空"
|
||||
desc.length > 100 -> "智能体描述长度不能超过100个字符"
|
||||
else -> null
|
||||
|
||||
@@ -79,7 +79,6 @@ fun FormTextInput2(
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(top = 8.dp)
|
||||
) {
|
||||
if (value.isEmpty()) {
|
||||
Text(
|
||||
|
||||
@@ -17,13 +17,13 @@ sealed class NavigationItem(
|
||||
|
||||
data object Home : NavigationItem("Home",
|
||||
icon = { R.drawable.rider_pro_nav_home },
|
||||
selectedIcon = { R.mipmap.rider_pro_nav_home_hl },
|
||||
selectedIcon = { R.mipmap.bars_x_buttons_home_s },
|
||||
label = { stringResource(R.string.main_home) }
|
||||
)
|
||||
|
||||
data object Ai : NavigationItem("Ai",
|
||||
icon = { R.mipmap.bars_x_buttons_discover_bold},
|
||||
selectedIcon = { R.mipmap.dynamic_hl },
|
||||
selectedIcon = { R.mipmap.bars_x_buttons_discover_fill },
|
||||
label = { stringResource(R.string.index_dynamic) }
|
||||
)
|
||||
// data object Ai : NavigationItem("Ai",
|
||||
@@ -40,13 +40,13 @@ sealed class NavigationItem(
|
||||
|
||||
data object Notification : NavigationItem("Notification",
|
||||
icon = { R.drawable.rider_pro_nav_notification },
|
||||
selectedIcon = { R.mipmap.rider_pro_nav_message_hl },
|
||||
selectedIcon = { R.mipmap.bars_x_buttons_chat_s },
|
||||
label = { stringResource(R.string.main_message) }
|
||||
)
|
||||
|
||||
data object Profile : NavigationItem("Profile",
|
||||
icon = { R.drawable.rider_pro_nav_profile },
|
||||
selectedIcon = { R.mipmap.rider_pro_nav_profile_hl },
|
||||
selectedIcon = { R.mipmap.bars_x_buttons_user_s },
|
||||
label = { stringResource(R.string.main_profile) }
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user