@@ -45,6 +45,7 @@ object AppState {
|
|||||||
var googleClientId: String? = null
|
var googleClientId: String? = null
|
||||||
var enableGoogleLogin: Boolean = false
|
var enableGoogleLogin: Boolean = false
|
||||||
var enableChat = false
|
var enableChat = false
|
||||||
|
var agentCreatedSuccess by mutableStateOf(false)
|
||||||
suspend fun initWithAccount(scope: CoroutineScope, context: Context) {
|
suspend fun initWithAccount(scope: CoroutineScope, context: Context) {
|
||||||
// 如果是游客模式,使用简化的初始化流程
|
// 如果是游客模式,使用简化的初始化流程
|
||||||
if (AppStore.isGuest) {
|
if (AppStore.isGuest) {
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import com.aiosman.ravenow.ui.chat.ChatScreen
|
|||||||
import com.aiosman.ravenow.ui.chat.GroupChatScreen
|
import com.aiosman.ravenow.ui.chat.GroupChatScreen
|
||||||
import com.aiosman.ravenow.ui.comment.CommentsScreen
|
import com.aiosman.ravenow.ui.comment.CommentsScreen
|
||||||
import com.aiosman.ravenow.ui.comment.notice.CommentNoticeScreen
|
import com.aiosman.ravenow.ui.comment.notice.CommentNoticeScreen
|
||||||
|
import com.aiosman.ravenow.ui.composables.AgentCreatedSuccessIndicator
|
||||||
import com.aiosman.ravenow.ui.crop.ImageCropScreen
|
import com.aiosman.ravenow.ui.crop.ImageCropScreen
|
||||||
import com.aiosman.ravenow.ui.favourite.FavouriteListPage
|
import com.aiosman.ravenow.ui.favourite.FavouriteListPage
|
||||||
import com.aiosman.ravenow.ui.favourite.FavouriteNoticeScreen
|
import com.aiosman.ravenow.ui.favourite.FavouriteNoticeScreen
|
||||||
@@ -615,6 +616,7 @@ fun Navigation(
|
|||||||
navController = navController,
|
navController = navController,
|
||||||
startDestination = startDestination
|
startDestination = startDestination
|
||||||
)
|
)
|
||||||
|
AgentCreatedSuccessIndicator()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ import androidx.compose.ui.draw.alpha
|
|||||||
import androidx.compose.ui.focus.focusRequester
|
import androidx.compose.ui.focus.focusRequester
|
||||||
import androidx.compose.ui.graphics.asImageBitmap
|
import androidx.compose.ui.graphics.asImageBitmap
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
||||||
|
import com.aiosman.ravenow.ui.agent.AddAgentViewModel.showManualCreation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加智能体界面
|
* 添加智能体界面
|
||||||
*/
|
*/
|
||||||
@@ -154,15 +156,32 @@ fun AddAgentScreen() {
|
|||||||
// 页面进入时重置头像选择状态
|
// 页面进入时重置头像选择状态
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
model.isSelectingAvatar = false
|
model.isSelectingAvatar = false
|
||||||
|
// 根据标记恢复相应的状态
|
||||||
|
if (model.isAutoModeManualForm) {
|
||||||
|
// 恢复自动模式下的手动表单状态
|
||||||
|
showManualCreationForm = model.showManualCreationForm
|
||||||
|
isCreatingAgent = model.isCreatingAgent
|
||||||
|
showWaveAnimation = model.showWaveAnimation
|
||||||
|
showManualCreation = model.showManualCreation
|
||||||
|
} else {
|
||||||
|
// 恢复手动模式下的状态
|
||||||
|
showManualCreation = model.showManualCreation
|
||||||
|
showManualCreationForm = model.showManualCreationForm
|
||||||
|
isCreatingAgent = model.isCreatingAgent
|
||||||
|
showWaveAnimation = model.showWaveAnimation
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.background(color = appColors.decentBackground),
|
.background(color = appColors.decentBackground),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
var showManualCreation by remember { mutableStateOf(false) }
|
var showManualCreation by remember {
|
||||||
|
mutableStateOf(model.showManualCreation)
|
||||||
|
}
|
||||||
StatusBarSpacer()
|
StatusBarSpacer()
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier.padding(horizontal = 14.dp, vertical = 16.dp)
|
modifier = Modifier.padding(horizontal = 14.dp, vertical = 16.dp)
|
||||||
@@ -227,6 +246,7 @@ fun AddAgentScreen() {
|
|||||||
Text(
|
Text(
|
||||||
text = "${AppState.profile?.nickName ?: "User"} ${stringResource(R.string.welcome_1)}",
|
text = "${AppState.profile?.nickName ?: "User"} ${stringResource(R.string.welcome_1)}",
|
||||||
fontSize = 16.sp,
|
fontSize = 16.sp,
|
||||||
|
color = appColors.text,
|
||||||
fontWeight = FontWeight.W600
|
fontWeight = FontWeight.W600
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -240,7 +260,7 @@ fun AddAgentScreen() {
|
|||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.welcome_2),
|
text = stringResource(R.string.welcome_2),
|
||||||
fontSize = 14.sp,
|
fontSize = 14.sp,
|
||||||
color = LocalAppTheme.current.text.copy(alpha = 0.6f),
|
color = appColors.text.copy(alpha = 0.6f),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -457,7 +477,7 @@ fun AddAgentScreen() {
|
|||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.ideaing),
|
text = stringResource(R.string.ideaing),
|
||||||
color = Color.Black.copy(alpha = 0.6f),
|
color = appColors.text.copy(alpha = 0.6f),
|
||||||
fontSize = 14.sp
|
fontSize = 14.sp
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -470,6 +490,7 @@ fun AddAgentScreen() {
|
|||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.avatar),
|
text = stringResource(R.string.avatar),
|
||||||
fontSize = 12.sp,
|
fontSize = 12.sp,
|
||||||
|
color = appColors.text,
|
||||||
fontWeight = FontWeight.W600
|
fontWeight = FontWeight.W600
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
@@ -488,6 +509,12 @@ fun AddAgentScreen() {
|
|||||||
)
|
)
|
||||||
.align(Alignment.Start)
|
.align(Alignment.Start)
|
||||||
.noRippleClickable {
|
.noRippleClickable {
|
||||||
|
// 保存当前状态
|
||||||
|
model.showManualCreationForm = showManualCreationForm
|
||||||
|
model.isCreatingAgent = isCreatingAgent
|
||||||
|
model.showWaveAnimation = showWaveAnimation
|
||||||
|
model.showManualCreation = showManualCreation
|
||||||
|
model.isAutoModeManualForm = true // 标记为自动模式下的手动表单
|
||||||
// 设置正在选择头像的标志
|
// 设置正在选择头像的标志
|
||||||
model.isSelectingAvatar = true
|
model.isSelectingAvatar = true
|
||||||
navController.navigate(NavigationRoute.AgentImageCrop.route)
|
navController.navigate(NavigationRoute.AgentImageCrop.route)
|
||||||
@@ -518,6 +545,7 @@ fun AddAgentScreen() {
|
|||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.agent_name),
|
text = stringResource(R.string.agent_name),
|
||||||
fontSize = 12.sp,
|
fontSize = 12.sp,
|
||||||
|
color = appColors.text,
|
||||||
fontWeight = FontWeight.W600
|
fontWeight = FontWeight.W600
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
@@ -532,6 +560,7 @@ fun AddAgentScreen() {
|
|||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.agent_desc),
|
text = stringResource(R.string.agent_desc),
|
||||||
fontSize = 12.sp,
|
fontSize = 12.sp,
|
||||||
|
color = appColors.text,
|
||||||
fontWeight = FontWeight.W600
|
fontWeight = FontWeight.W600
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
@@ -575,12 +604,13 @@ fun AddAgentScreen() {
|
|||||||
Icon(
|
Icon(
|
||||||
painter = painterResource(id = R.mipmap.icons_infor_edit),
|
painter = painterResource(id = R.mipmap.icons_infor_edit),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
|
tint = appColors.text,
|
||||||
modifier = Modifier.size(18.dp),
|
modifier = Modifier.size(18.dp),
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.width(8.dp))
|
Spacer(modifier = Modifier.width(8.dp))
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.create_agent_hand),
|
text = stringResource(R.string.create_agent_hand),
|
||||||
color = Color.Black,
|
color = appColors.text,
|
||||||
fontWeight = FontWeight.W600,
|
fontWeight = FontWeight.W600,
|
||||||
fontSize = 14.sp
|
fontSize = 14.sp
|
||||||
)
|
)
|
||||||
@@ -640,13 +670,13 @@ fun AddAgentScreen() {
|
|||||||
Icon(
|
Icon(
|
||||||
painter = painterResource(id = R.mipmap.icons_info_magic),
|
painter = painterResource(id = R.mipmap.icons_info_magic),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
tint = Color.Black,
|
tint = appColors.text,
|
||||||
modifier = Modifier.size(18.dp),
|
modifier = Modifier.size(18.dp),
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.width(8.dp))
|
Spacer(modifier = Modifier.width(8.dp))
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.create_agent_auto),
|
text = stringResource(R.string.create_agent_auto),
|
||||||
color = Color.Black,
|
color = appColors.text,
|
||||||
fontWeight = FontWeight.W600,
|
fontWeight = FontWeight.W600,
|
||||||
fontSize = 14.sp
|
fontSize = 14.sp
|
||||||
)
|
)
|
||||||
@@ -657,6 +687,7 @@ fun AddAgentScreen() {
|
|||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.avatar),
|
text = stringResource(R.string.avatar),
|
||||||
fontSize = 12.sp,
|
fontSize = 12.sp,
|
||||||
|
color = appColors.text,
|
||||||
fontWeight = FontWeight.W600
|
fontWeight = FontWeight.W600
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
@@ -675,6 +706,12 @@ fun AddAgentScreen() {
|
|||||||
)
|
)
|
||||||
.align(Alignment.Start)
|
.align(Alignment.Start)
|
||||||
.noRippleClickable {
|
.noRippleClickable {
|
||||||
|
// 保存当前状态
|
||||||
|
model.showManualCreation = showManualCreation
|
||||||
|
model.showManualCreationForm = showManualCreationForm
|
||||||
|
model.isCreatingAgent = isCreatingAgent
|
||||||
|
model.showWaveAnimation = showWaveAnimation
|
||||||
|
model.isAutoModeManualForm = false // 标记为手动模式下的手动表单
|
||||||
// 设置正在选择头像的标志
|
// 设置正在选择头像的标志
|
||||||
model.isSelectingAvatar = true
|
model.isSelectingAvatar = true
|
||||||
navController.navigate(NavigationRoute.AgentImageCrop.route)
|
navController.navigate(NavigationRoute.AgentImageCrop.route)
|
||||||
@@ -710,6 +747,7 @@ fun AddAgentScreen() {
|
|||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.agent_name),
|
text = stringResource(R.string.agent_name),
|
||||||
fontSize = 12.sp,
|
fontSize = 12.sp,
|
||||||
|
color = appColors.text,
|
||||||
fontWeight = FontWeight.W600
|
fontWeight = FontWeight.W600
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
@@ -724,6 +762,7 @@ fun AddAgentScreen() {
|
|||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.agent_desc),
|
text = stringResource(R.string.agent_desc),
|
||||||
fontSize = 12.sp,
|
fontSize = 12.sp,
|
||||||
|
color = appColors.text,
|
||||||
fontWeight = FontWeight.W600
|
fontWeight = FontWeight.W600
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
@@ -753,7 +792,6 @@ fun AddAgentScreen() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionButton(
|
ActionButton(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(345.dp)
|
.width(345.dp)
|
||||||
@@ -797,6 +835,7 @@ fun AddAgentScreen() {
|
|||||||
// 创建成功,清空数据并关闭页面
|
// 创建成功,清空数据并关闭页面
|
||||||
model.clearData()
|
model.clearData()
|
||||||
navController.popBackStack()
|
navController.popBackStack()
|
||||||
|
AppState.agentCreatedSuccess = true
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
// 显示错误信息
|
// 显示错误信息
|
||||||
|
|||||||
@@ -24,7 +24,12 @@ object AddAgentViewModel : ViewModel() {
|
|||||||
var croppedBitmap by mutableStateOf<Bitmap?>(null)
|
var croppedBitmap by mutableStateOf<Bitmap?>(null)
|
||||||
var isUpdating by mutableStateOf(false)
|
var isUpdating by mutableStateOf(false)
|
||||||
var isSelectingAvatar by mutableStateOf(false) // 标记是否正在选择头像
|
var isSelectingAvatar by mutableStateOf(false) // 标记是否正在选择头像
|
||||||
|
var showManualCreationForm by mutableStateOf(false)
|
||||||
|
var isCreatingAgent by mutableStateOf(false)
|
||||||
|
var showWaveAnimation by mutableStateOf(false)
|
||||||
|
var showManualCreation by mutableStateOf(false)
|
||||||
|
// 添加一个标志来区分两种手动表单状态
|
||||||
|
var isAutoModeManualForm by mutableStateOf(false)
|
||||||
suspend fun updateAgentAvatar(context: Context) {
|
suspend fun updateAgentAvatar(context: Context) {
|
||||||
croppedBitmap?.let {
|
croppedBitmap?.let {
|
||||||
val file = File(context.cacheDir, "agent_avatar.jpg")
|
val file = File(context.cacheDir, "agent_avatar.jpg")
|
||||||
@@ -84,5 +89,10 @@ object AddAgentViewModel : ViewModel() {
|
|||||||
croppedBitmap = null
|
croppedBitmap = null
|
||||||
isUpdating = false
|
isUpdating = false
|
||||||
isSelectingAvatar = false
|
isSelectingAvatar = false
|
||||||
|
showManualCreationForm = false
|
||||||
|
isCreatingAgent = false
|
||||||
|
showWaveAnimation = false
|
||||||
|
showManualCreation = false
|
||||||
|
isAutoModeManualForm = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package com.aiosman.ravenow.ui.composables
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.res.painterResource
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import com.aiosman.ravenow.AppState
|
||||||
|
import com.aiosman.ravenow.LocalAppTheme
|
||||||
|
import com.aiosman.ravenow.R
|
||||||
|
import com.aiosman.ravenow.ui.composables.toolbar.CollapsingToolbarScaffoldScopeInstance.align
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun AgentCreatedSuccessIndicator() {
|
||||||
|
val appColors = LocalAppTheme.current
|
||||||
|
if (AppState.agentCreatedSuccess) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(bottom = 70.dp),
|
||||||
|
contentAlignment = Alignment.BottomCenter
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.width(150.dp)
|
||||||
|
.height(40.dp)
|
||||||
|
.background(appColors.text.copy(alpha = 0.5f), shape = RoundedCornerShape(15.dp)),
|
||||||
|
contentAlignment = Alignment.CenterStart
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
modifier = Modifier.padding(horizontal = 8.dp, vertical = 6.dp)
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
painter = painterResource(id = R.mipmap.bars_x_buttons_home_n_copy_2),
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier.size(20.dp),
|
||||||
|
tint = Color.Unspecified
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.width(7.dp))
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.create_success),
|
||||||
|
color = appColors.background,
|
||||||
|
fontSize = 13.sp
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
delay(3000)
|
||||||
|
AppState.agentCreatedSuccess = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ fun FormTextInput(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(16.dp)
|
.size(16.dp)
|
||||||
.align(Alignment.TopStart),
|
.align(Alignment.TopStart),
|
||||||
tint = Color.Unspecified.copy(alpha = 0.4f)
|
tint = AppColors.text.copy(alpha = 0.4f)
|
||||||
)
|
)
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ fun FormTextInput2(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(16.dp)
|
.size(16.dp)
|
||||||
.align(Alignment.TopStart),
|
.align(Alignment.TopStart),
|
||||||
tint = Color.Unspecified.copy(alpha = 0.4f)
|
tint = AppColors.text.copy(alpha = 0.4f)
|
||||||
)
|
)
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ fun CreateBottomSheet(
|
|||||||
painter = painterResource(R.mipmap.h_cj_rw_icon),
|
painter = painterResource(R.mipmap.h_cj_rw_icon),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(start = 16.dp)
|
.padding(start = 16.dp),
|
||||||
|
colorFilter = androidx.compose.ui.graphics.ColorFilter.tint(appColors.text)
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
Text(
|
Text(
|
||||||
@@ -81,7 +82,8 @@ fun CreateBottomSheet(
|
|||||||
painter = painterResource(R.mipmap.h_cj_x_img),
|
painter = painterResource(R.mipmap.h_cj_x_img),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(end = 18.dp)
|
.padding(end = 18.dp),
|
||||||
|
colorFilter = androidx.compose.ui.graphics.ColorFilter.tint(appColors.text)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user