页面样式调整
This commit is contained in:
@@ -18,7 +18,8 @@ import com.aiosman.ravenow.ui.favourite.FavouriteNoticeViewModel
|
||||
import com.aiosman.ravenow.ui.follower.FollowerNoticeViewModel
|
||||
import com.aiosman.ravenow.ui.index.IndexViewModel
|
||||
import com.aiosman.ravenow.ui.index.tabs.message.MessageListViewModel
|
||||
import com.aiosman.ravenow.ui.index.tabs.moment.tabs.expolre.MomentExploreViewModel
|
||||
import com.aiosman.ravenow.ui.index.tabs.moment.tabs.expolre.Explore
|
||||
import com.aiosman.ravenow.ui.index.tabs.moment.tabs.expolre.ExploreViewModel
|
||||
import com.aiosman.ravenow.ui.index.tabs.moment.tabs.hot.HotMomentViewModel
|
||||
import com.aiosman.ravenow.ui.index.tabs.moment.tabs.timeline.TimelineMomentViewModel
|
||||
import com.aiosman.ravenow.ui.index.tabs.profile.MyProfileViewModel
|
||||
@@ -151,7 +152,7 @@ object AppState {
|
||||
fun ReloadAppState(context: Context) {
|
||||
// 重置动态列表页面
|
||||
TimelineMomentViewModel.ResetModel()
|
||||
MomentExploreViewModel.ResetModel()
|
||||
ExploreViewModel.ResetModel()
|
||||
HotMomentViewModel.ResetModel()
|
||||
|
||||
// 重置我的页面
|
||||
|
||||
88
app/src/main/java/com/aiosman/ravenow/data/RoomService.kt
Normal file
88
app/src/main/java/com/aiosman/ravenow/data/RoomService.kt
Normal file
@@ -0,0 +1,88 @@
|
||||
package com.aiosman.ravenow.data
|
||||
|
||||
import com.aiosman.ravenow.AppStore
|
||||
import com.aiosman.ravenow.data.api.ApiClient
|
||||
import com.aiosman.ravenow.entity.AgentEntity
|
||||
import com.aiosman.ravenow.entity.CreatorEntity
|
||||
import com.aiosman.ravenow.entity.ProfileEntity
|
||||
import com.aiosman.ravenow.entity.RoomEntity
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class Room(
|
||||
@SerializedName("id")
|
||||
val id: Int,
|
||||
@SerializedName("name")
|
||||
val name: String,
|
||||
@SerializedName("description")
|
||||
val description: String,
|
||||
@SerializedName("trtcRoomId")
|
||||
val trtcRoomId: String,
|
||||
@SerializedName("trtcType")
|
||||
val trtcType: String,
|
||||
@SerializedName("cover")
|
||||
val cover: String,
|
||||
@SerializedName("avatar")
|
||||
val avatar: String,
|
||||
@SerializedName("recommendBanner")
|
||||
val recommendBanner: String,
|
||||
@SerializedName("isRecommended")
|
||||
val isRecommended: Boolean,
|
||||
@SerializedName("allowInHot")
|
||||
val allowInHot: Boolean,
|
||||
@SerializedName("creator")
|
||||
val creator: Creator,
|
||||
@SerializedName("userCount")
|
||||
val userCount: Int,
|
||||
@SerializedName("maxMemberLimit")
|
||||
val maxMemberLimit: Int,
|
||||
@SerializedName("canJoin")
|
||||
val canJoin: Boolean,
|
||||
@SerializedName("canJoinCode")
|
||||
val canJoinCode: Int
|
||||
|
||||
) {
|
||||
fun toRoomtEntity(): RoomEntity {
|
||||
return RoomEntity(
|
||||
id= id,
|
||||
name = name,
|
||||
description = description ,
|
||||
trtcRoomId = trtcRoomId,
|
||||
trtcType = trtcType,
|
||||
cover = cover,
|
||||
avatar = avatar,
|
||||
recommendBanner = recommendBanner,
|
||||
isRecommended = isRecommended,
|
||||
allowInHot = allowInHot,
|
||||
creator = creator.toCreatorEntity(),
|
||||
userCount = userCount,
|
||||
maxMemberLimit = maxMemberLimit,
|
||||
canJoin = canJoin,
|
||||
canJoinCode = canJoinCode,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
data class Creator(
|
||||
@SerializedName("id")
|
||||
val id: Int,
|
||||
@SerializedName("userId")
|
||||
val userId: String,
|
||||
@SerializedName("trtcUserId")
|
||||
val trtcUserId: String,
|
||||
@SerializedName("profile")
|
||||
val profile: Profile
|
||||
){
|
||||
fun toCreatorEntity(): CreatorEntity {
|
||||
return CreatorEntity(
|
||||
id = id,
|
||||
userId = userId,
|
||||
trtcUserId = trtcUserId,
|
||||
profile = profile.toProfileEntity()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.aiosman.ravenow.data.Comment
|
||||
import com.aiosman.ravenow.data.DataContainer
|
||||
import com.aiosman.ravenow.data.ListContainer
|
||||
import com.aiosman.ravenow.data.Moment
|
||||
import com.aiosman.ravenow.data.Room
|
||||
import com.aiosman.ravenow.entity.ChatNotification
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import okhttp3.MultipartBody
|
||||
@@ -541,7 +542,11 @@ interface RaveNowAPI {
|
||||
@POST("outside/rooms")
|
||||
suspend fun createGroupChat(@Body body: CreateGroupChatRequestBody): Response<DataContainer<Unit>>
|
||||
|
||||
|
||||
@GET("outside/rooms")
|
||||
suspend fun getRooms(@Query("page") page: Int = 1,
|
||||
@Query("pageSize") pageSize: Int = 20,
|
||||
@Query("isRecommended") isRecommended: Int = 1,
|
||||
): Response<ListContainer<Room>>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -62,17 +62,7 @@ data class AgentEntity(
|
||||
val useCount: Int,
|
||||
)
|
||||
|
||||
data class ProfileEntity(
|
||||
val aiAccount: Boolean,
|
||||
val avatar: String,
|
||||
val banner: String,
|
||||
val bio: String,
|
||||
val chatAIId: String,
|
||||
val id: Int,
|
||||
val nickname: String,
|
||||
val trtcUserId: String,
|
||||
val username: String
|
||||
)
|
||||
|
||||
fun createMultipartBody(file: File, filename: String, name: String): MultipartBody.Part {
|
||||
val requestFile = file.asRequestBody("image/*".toMediaTypeOrNull())
|
||||
return MultipartBody.Part.createFormData(name, filename, requestFile)
|
||||
|
||||
78
app/src/main/java/com/aiosman/ravenow/entity/Room.kt
Normal file
78
app/src/main/java/com/aiosman/ravenow/entity/Room.kt
Normal file
@@ -0,0 +1,78 @@
|
||||
package com.aiosman.ravenow.entity
|
||||
|
||||
import com.aiosman.ravenow.data.ListContainer
|
||||
import com.aiosman.ravenow.data.ServiceException
|
||||
import com.aiosman.ravenow.data.api.ApiClient
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.MultipartBody
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* 群聊房间
|
||||
*/
|
||||
|
||||
data class RoomEntity(
|
||||
val id: Int,
|
||||
val name: String,
|
||||
val description: String,
|
||||
val trtcRoomId: String,
|
||||
val trtcType: String,
|
||||
val cover: String,
|
||||
val avatar: String,
|
||||
val recommendBanner: String,
|
||||
val isRecommended: Boolean,
|
||||
val allowInHot: Boolean,
|
||||
val creator: CreatorEntity,
|
||||
val userCount: Int,
|
||||
val maxMemberLimit: Int,
|
||||
val canJoin: Boolean,
|
||||
val canJoinCode: Int,
|
||||
)
|
||||
|
||||
data class CreatorEntity(
|
||||
val id: Int,
|
||||
val userId: String,
|
||||
val trtcUserId: String,
|
||||
val profile: ProfileEntity
|
||||
)
|
||||
|
||||
data class ProfileEntity(
|
||||
val id: Int,
|
||||
val username: String,
|
||||
val nickname: String,
|
||||
val avatar: String,
|
||||
val banner: String,
|
||||
val bio: String,
|
||||
val trtcUserId: String,
|
||||
val chatAIId: String,
|
||||
val aiAccount: Boolean,
|
||||
)
|
||||
|
||||
class RoomLoader : DataLoader<AgentEntity,AgentLoaderExtraArgs>() {
|
||||
override suspend fun fetchData(
|
||||
page: Int,
|
||||
pageSize: Int,
|
||||
extra: AgentLoaderExtraArgs
|
||||
): ListContainer<AgentEntity> {
|
||||
val result = ApiClient.api.getAgent(
|
||||
page = page,
|
||||
pageSize = pageSize,
|
||||
|
||||
)
|
||||
val data = result.body()?.let {
|
||||
ListContainer(
|
||||
list = it.data.list.map { it.toAgentEntity()},
|
||||
total = it.data.total,
|
||||
page = page,
|
||||
pageSize = pageSize
|
||||
)
|
||||
}
|
||||
if (data == null) {
|
||||
throw ServiceException("Failed to get agent")
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -260,7 +260,7 @@ fun IndexScreen() {
|
||||
Scaffold(
|
||||
bottomBar = {
|
||||
NavigationBar(
|
||||
modifier = Modifier.height(72.dp + navigationBarHeight),
|
||||
modifier = Modifier.height(58.dp + navigationBarHeight),
|
||||
containerColor = AppColors.background
|
||||
) {
|
||||
item.forEachIndexed { idx, it ->
|
||||
@@ -271,7 +271,7 @@ fun IndexScreen() {
|
||||
)
|
||||
|
||||
NavigationBarItem(
|
||||
modifier = Modifier.padding(top = 6.dp),
|
||||
modifier = Modifier.padding(top = 2.dp),
|
||||
selected = isSelected,
|
||||
onClick = {
|
||||
if (it.route === NavigationItem.Add.route) {
|
||||
@@ -327,7 +327,7 @@ fun IndexScreen() {
|
||||
}
|
||||
|
||||
// 文字标签,可控制间距
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Spacer(modifier = Modifier.height(1.dp))
|
||||
|
||||
Text(
|
||||
text = it.label(),
|
||||
|
||||
@@ -24,7 +24,7 @@ sealed class NavigationItem(
|
||||
data object Ai : NavigationItem("Ai",
|
||||
icon = { R.drawable.rider_pro_nav_ai },
|
||||
selectedIcon = { R.mipmap.rider_pro_nav_ai_hl },
|
||||
label = { stringResource(R.string.main_home) }
|
||||
label = { stringResource(R.string.main_ai) }
|
||||
)
|
||||
|
||||
data object Add : NavigationItem("Add",
|
||||
|
||||
@@ -168,7 +168,7 @@ object GroupChatListViewModel : ViewModel() {
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
// 群聊直接使用群ID进行导航
|
||||
navController.navigateToChat(conversation.groupId)
|
||||
//navController.navigateToChat(conversation.groupId)
|
||||
} catch (e: Exception) {
|
||||
error = ""
|
||||
e.printStackTrace()
|
||||
|
||||
@@ -42,7 +42,8 @@ import com.aiosman.ravenow.LocalAppTheme
|
||||
import com.aiosman.ravenow.LocalNavController
|
||||
import com.aiosman.ravenow.R
|
||||
import com.aiosman.ravenow.ui.NavigationRoute
|
||||
import com.aiosman.ravenow.ui.index.tabs.moment.tabs.expolre.ExploreMomentsList
|
||||
import com.aiosman.ravenow.ui.index.tabs.moment.tabs.dynamic.Dynamic
|
||||
import com.aiosman.ravenow.ui.index.tabs.moment.tabs.expolre.Explore
|
||||
import com.aiosman.ravenow.ui.index.tabs.moment.tabs.hot.HotMomentsList
|
||||
import com.aiosman.ravenow.ui.index.tabs.moment.tabs.timeline.TimelineMomentsList
|
||||
import com.aiosman.ravenow.ui.index.tabs.search.SearchViewModel
|
||||
@@ -227,10 +228,10 @@ fun MomentsList() {
|
||||
) {
|
||||
when (it) {
|
||||
0 -> {
|
||||
//ExploreMomentsList()
|
||||
Dynamic()
|
||||
}
|
||||
1 -> {
|
||||
ExploreMomentsList()
|
||||
Explore()
|
||||
}
|
||||
|
||||
2 -> {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.aiosman.ravenow.ui.index.tabs.moment.tabs.dynamic
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.pullrefresh.PullRefreshIndicator
|
||||
import androidx.compose.material.pullrefresh.pullRefresh
|
||||
import androidx.compose.material.pullrefresh.rememberPullRefreshState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.aiosman.ravenow.ui.composables.MomentCard
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* 探索
|
||||
*/
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@Composable
|
||||
fun Dynamic() {
|
||||
val model = DynamicViewModel
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.aiosman.ravenow.ui.index.tabs.moment.tabs.dynamic
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.aiosman.ravenow.entity.MomentLoaderExtraArgs
|
||||
import com.aiosman.ravenow.ui.index.tabs.moment.BaseMomentModel
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
|
||||
object DynamicViewModel : ViewModel() {
|
||||
|
||||
|
||||
}
|
||||
@@ -25,8 +25,8 @@ import kotlinx.coroutines.launch
|
||||
*/
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@Composable
|
||||
fun ExploreMomentsList() {
|
||||
val model = MomentExploreViewModel
|
||||
fun Explore() {
|
||||
val model = ExploreViewModel
|
||||
var moments = model.moments
|
||||
|
||||
val scope = rememberCoroutineScope()
|
||||
@@ -5,7 +5,7 @@ import com.aiosman.ravenow.ui.index.tabs.moment.BaseMomentModel
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
|
||||
object MomentExploreViewModel : BaseMomentModel() {
|
||||
object ExploreViewModel : BaseMomentModel() {
|
||||
init {
|
||||
EventBus.getDefault().register(this)
|
||||
|
||||
Reference in New Issue
Block a user