我的智能体
This commit is contained in:
@@ -5,6 +5,7 @@ import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
@@ -78,6 +79,10 @@ class MainActivity : ComponentActivity() {
|
||||
@RequiresApi(Build.VERSION_CODES.P)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
// 设置屏幕方向为竖屏
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
|
||||
// 监听应用生命周期
|
||||
ProcessLifecycleOwner.get().lifecycle.addObserver(MainActivityLifecycleObserver())
|
||||
// 创建通知渠道
|
||||
|
||||
@@ -55,7 +55,7 @@ fun AccountEditScreen2() {
|
||||
fun onNicknameChange(value: String) {
|
||||
model.name = value
|
||||
usernameError = when {
|
||||
value.isEmpty() -> "昵称不能为空"
|
||||
value.trim().isEmpty() -> "昵称不能为空"
|
||||
value.length < 3 -> "昵称长度不能小于3"
|
||||
value.length > 20 -> "昵称长度不能大于20"
|
||||
else -> null
|
||||
|
||||
@@ -487,9 +487,7 @@ fun MomentBottomOperateRowGroup(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.fillMaxHeight()
|
||||
.noRippleClickable {
|
||||
onFavoriteClick()
|
||||
},
|
||||
,
|
||||
contentAlignment = Alignment.CenterEnd
|
||||
) {
|
||||
MomentOperateBtn(count = momentEntity.favoriteCount.toString()) {
|
||||
|
||||
@@ -19,6 +19,7 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import com.aiosman.ravenow.AppState
|
||||
import com.aiosman.ravenow.LocalAppTheme
|
||||
import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.exp.viewModelFactory
|
||||
@@ -41,9 +42,9 @@ fun FollowerListScreen(userId: Int) {
|
||||
model.loadData(userId)
|
||||
}
|
||||
StatusBarMaskLayout(
|
||||
modifier = Modifier
|
||||
.background(color = appColors.background)
|
||||
.padding(horizontal = 16.dp),
|
||||
modifier = Modifier.background(color = appColors.background).padding(horizontal = 16.dp),
|
||||
darkIcons = !AppState.darkMode,
|
||||
maskBoxBackgroundColor = appColors.background
|
||||
) {
|
||||
var dataFlow = model.usersFlow
|
||||
var users = dataFlow.collectAsLazyPagingItems()
|
||||
|
||||
@@ -26,6 +26,7 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import com.aiosman.ravenow.AppState
|
||||
import com.aiosman.ravenow.LocalAppTheme
|
||||
import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.exp.viewModelFactory
|
||||
@@ -48,9 +49,9 @@ fun FollowingListScreen(userId: Int) {
|
||||
model.loadData(userId)
|
||||
}
|
||||
StatusBarMaskLayout(
|
||||
modifier = Modifier
|
||||
.background(color = appColors.background)
|
||||
.padding(horizontal = 16.dp),
|
||||
modifier = Modifier.background(color = appColors.background).padding(horizontal = 16.dp),
|
||||
darkIcons = !AppState.darkMode,
|
||||
maskBoxBackgroundColor = appColors.background
|
||||
) {
|
||||
var dataFlow = model.usersFlow
|
||||
var users = dataFlow.collectAsLazyPagingItems()
|
||||
|
||||
@@ -107,6 +107,7 @@ fun ProfileV3(
|
||||
onChatClick: () -> Unit = {},
|
||||
moments: List<MomentEntity>,
|
||||
isSelf: Boolean = true,
|
||||
isMain:Boolean = false,
|
||||
onLoadMore: () -> Unit = {},
|
||||
onLike: (MomentEntity) -> Unit = {},
|
||||
onComment: (MomentEntity) -> Unit = {},
|
||||
@@ -274,7 +275,7 @@ fun ProfileV3(
|
||||
)
|
||||
}
|
||||
}
|
||||
if (isSelf) {
|
||||
if (isSelf&&isMain) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.align(Alignment.TopEnd)
|
||||
@@ -386,54 +387,57 @@ fun ProfileV3(
|
||||
),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.rider_pro_back_icon), // Replace with your image resource
|
||||
contentDescription = "Back",
|
||||
modifier = Modifier
|
||||
.noRippleClickable {
|
||||
navController.navigateUp()
|
||||
}
|
||||
.size(24.dp),
|
||||
colorFilter = ColorFilter.tint(AppColors.text)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
CustomAsyncImage(
|
||||
LocalContext.current,
|
||||
profile?.avatar,
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.clip(CircleShape),
|
||||
contentDescription = "",
|
||||
contentScale = ContentScale.Crop
|
||||
)
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
Text(
|
||||
text = profile?.nickName ?: "",
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.W600,
|
||||
color = AppColors.text
|
||||
)
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
if (isSelf) {
|
||||
Box(
|
||||
modifier = Modifier.noRippleClickable {
|
||||
IndexViewModel.openDrawer = true
|
||||
}
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
if (!isMain) {
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.rider_pro_back_icon), // Replace with your image resource
|
||||
contentDescription = "Back",
|
||||
modifier = Modifier
|
||||
.noRippleClickable {
|
||||
navController.navigateUp()
|
||||
}
|
||||
.size(24.dp),
|
||||
colorFilter = ColorFilter.tint(AppColors.text)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
CustomAsyncImage(
|
||||
LocalContext.current,
|
||||
profile?.avatar,
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.clip(CircleShape),
|
||||
contentDescription = "",
|
||||
contentScale = ContentScale.Crop
|
||||
)
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
Text(
|
||||
text = profile?.nickName ?: "",
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.W600,
|
||||
color = AppColors.text
|
||||
)
|
||||
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.rider_pro_more_horizon),
|
||||
contentDescription = "",
|
||||
tint = AppColors.text
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
if (isSelf&&isMain) {
|
||||
Box(
|
||||
modifier = Modifier.noRippleClickable {
|
||||
IndexViewModel.openDrawer = true
|
||||
}
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.rider_pro_more_horizon),
|
||||
contentDescription = "",
|
||||
tint = AppColors.text
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
@@ -16,6 +16,7 @@ fun ProfileWrap(
|
||||
MyProfileViewModel.loadProfile()
|
||||
}
|
||||
ProfileV3(
|
||||
isMain = true,
|
||||
onUpdateBanner = { uri, file, context ->
|
||||
MyProfileViewModel.updateUserProfileBanner(uri, file, context)
|
||||
},
|
||||
|
||||
@@ -85,7 +85,9 @@ import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
|
||||
|
||||
/**
|
||||
* 发布动态
|
||||
*/
|
||||
@Preview
|
||||
@Composable
|
||||
fun NewPostScreen() {
|
||||
|
||||
@@ -123,6 +123,9 @@ import kotlinx.coroutines.launch
|
||||
import net.engawapg.lib.zoomable.rememberZoomState
|
||||
import net.engawapg.lib.zoomable.zoomable
|
||||
|
||||
/**
|
||||
* 动态详情
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun PostScreen(
|
||||
@@ -689,6 +692,7 @@ fun Header(
|
||||
windowInsets = WindowInsets(0)
|
||||
) {
|
||||
PostMenuModal(
|
||||
|
||||
onDeleteClick = {
|
||||
onDeleteClick()
|
||||
expanded = false
|
||||
@@ -696,7 +700,8 @@ fun Header(
|
||||
onReportClick = {
|
||||
onReportClick()
|
||||
expanded = false
|
||||
}
|
||||
},
|
||||
userId = userId
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1214,7 +1219,7 @@ fun CommentItem(
|
||||
color = AppColors.nonActiveText,
|
||||
)
|
||||
Spacer(modifier = Modifier.width(27.dp))
|
||||
if (AppState.UserId?.toLong() != commentEntity.author) {
|
||||
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.rider_pro_comment),
|
||||
contentDescription = "",
|
||||
@@ -1236,7 +1241,7 @@ fun CommentItem(
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1375,11 +1380,11 @@ fun PostBottomBar(
|
||||
fun PostMenuModal(
|
||||
onDeleteClick: () -> Unit = {},
|
||||
onReportClick: () -> Unit = {},
|
||||
momentEntity: MomentEntity? = null
|
||||
userId: Int? = 0
|
||||
) {
|
||||
val AppColors = LocalAppTheme.current
|
||||
|
||||
Column(
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(160.dp)
|
||||
@@ -1388,10 +1393,10 @@ fun PostMenuModal(
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(),
|
||||
.size(60.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
momentEntity?.let {
|
||||
if(AppState.UserId == userId){
|
||||
Column(
|
||||
modifier = Modifier.padding(end = 16.dp),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
@@ -1417,44 +1422,52 @@ fun PostMenuModal(
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.delete),
|
||||
fontSize = 11.sp,
|
||||
fontSize = 12.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = AppColors.text
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Column(
|
||||
modifier = Modifier.padding(end = 16.dp),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.size(60.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.clip(CircleShape)
|
||||
.noRippleClickable {
|
||||
onReportClick()
|
||||
if(AppState.UserId == userId){
|
||||
Column(
|
||||
modifier = Modifier.padding(end = 16.dp),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.clip(CircleShape)
|
||||
.noRippleClickable {
|
||||
onReportClick()
|
||||
}
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.rider_pro_moment_report),
|
||||
contentDescription = "",
|
||||
modifier = Modifier.size(24.dp),
|
||||
colorFilter = ColorFilter.tint(
|
||||
AppColors.error
|
||||
)
|
||||
)
|
||||
}
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.rider_pro_moment_delete),
|
||||
contentDescription = "",
|
||||
modifier = Modifier.size(24.dp),
|
||||
colorFilter = ColorFilter.tint(
|
||||
AppColors.text
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.report),
|
||||
fontSize = 12.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = AppColors.error
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.report),
|
||||
fontSize = 11.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = AppColors.text
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1621,7 +1634,7 @@ fun CommentMenuModal(
|
||||
onCloseClick()
|
||||
}
|
||||
}
|
||||
if (!isSelf) {
|
||||
//自己也可以回复自己
|
||||
Spacer(modifier = Modifier.width(48.dp))
|
||||
MenuActionItem(
|
||||
icon = R.drawable.rider_pro_comment,
|
||||
@@ -1629,7 +1642,7 @@ fun CommentMenuModal(
|
||||
) {
|
||||
onReplyClick()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Spacer(modifier = Modifier.height(48.dp))
|
||||
}
|
||||
|
||||
@@ -42,7 +42,12 @@ class AccountProfileViewModel : ViewModel() {
|
||||
if (profileId == profile?.id) {
|
||||
return@launch
|
||||
}
|
||||
profile = userService.getUserProfile(id)
|
||||
try {
|
||||
profile = userService.getUserProfile(id)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
refreshing = false
|
||||
profile?.let {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user