启动图标;动态界面调整

This commit is contained in:
2025-09-08 18:06:39 +08:00
parent 0aa3069efe
commit 21cb512237
17 changed files with 185 additions and 169 deletions

View File

@@ -160,7 +160,7 @@ fun EditCommentBottomModal(
painter = painterResource(id = R.mipmap.rider_pro_moment_post),
contentDescription = "Send",
modifier = Modifier
.size(25.dp)
.size(20.dp)
.align(Alignment.Top)
.noRippleClickable {
if (text.isNotEmpty()) {
@@ -168,7 +168,7 @@ fun EditCommentBottomModal(
text = ""
}
},
tint = if (isNotEmpty) AppColors.main else AppColors.nonActive
tint = if (isNotEmpty) Color.Unspecified else AppColors.nonActive
)
}
}

View File

@@ -91,6 +91,7 @@ fun IndexScreen() {
val navController = LocalNavController.current
val item = listOf(
NavigationItem.Home,
//NavigationItem.Dynamic,
NavigationItem.Ai,
NavigationItem.Add,
NavigationItem.Notification,
@@ -101,7 +102,7 @@ fun IndexScreen() {
val coroutineScope = rememberCoroutineScope()
val drawerState = rememberDrawerState(DrawerValue.Closed)
val context = LocalContext.current
// 注意:不要在离开 Index 路由时全量清理资源,以免返回后列表被重置
LaunchedEffect(Unit) {
systemUiController.setNavigationBarColor(Color.Transparent)
@@ -295,7 +296,7 @@ fun IndexScreen() {
navController.navigate(NavigationRoute.NewPost.route)
return@noRippleClickable
}
// 检查消息tab的游客模式
if (it.route === NavigationItem.Notification.route) {
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.VIEW_MESSAGES)) {
@@ -303,7 +304,7 @@ fun IndexScreen() {
return@noRippleClickable
}
}
// 检查我的tab的游客模式
if (it.route === NavigationItem.Profile.route) {
if (GuestLoginCheckOut.needLogin(GuestLoginCheckOutScene.VIEW_PROFILE)) {
@@ -311,7 +312,7 @@ fun IndexScreen() {
return@noRippleClickable
}
}
coroutineScope.launch {
pagerState.scrollToPage(idx)
}
@@ -378,8 +379,8 @@ fun IndexScreen() {
userScrollEnabled = false
) { page ->
when (page) {
0 -> Home()
1 -> Agent()
0 -> Agent()
1 -> Home()
2 -> Add()
3 -> Notifications()
4 -> Profile()
@@ -396,13 +397,13 @@ fun IndexScreen() {
fun Home() {
val systemUiController = rememberSystemUiController()
val context = LocalContext.current
LaunchedEffect(AppState.darkMode) {
systemUiController.setStatusBarColor(Color.Transparent, darkIcons = !AppState.darkMode)
}
// 注意:避免在离开 Home 时清理动态资源,防止返回详情后触发重新加载
Column(
modifier = Modifier
.fillMaxSize(),
@@ -418,18 +419,18 @@ fun Home() {
fun Street() {
val systemUiController = rememberSystemUiController()
val context = LocalContext.current
LaunchedEffect(AppState.darkMode) {
systemUiController.setStatusBarColor(Color.Transparent, darkIcons = !AppState.darkMode)
}
// 页面退出时清理搜索相关资源
DisposableEffect(Unit) {
onDispose {
ResourceCleanupManager.cleanupPageResources("search")
}
}
Column(
modifier = Modifier
.fillMaxSize(),
@@ -478,18 +479,18 @@ fun Video() {
fun Profile() {
val systemUiController = rememberSystemUiController()
val context = LocalContext.current
LaunchedEffect(AppState.darkMode) {
systemUiController.setStatusBarColor(Color.Transparent, !AppState.darkMode)
}
// 页面退出时清理个人资料相关资源
DisposableEffect(Unit) {
onDispose {
ResourceCleanupManager.cleanupPageResources("profile")
}
}
Column(
modifier = Modifier
.fillMaxSize(),
@@ -504,18 +505,18 @@ fun Profile() {
fun Notifications() {
val systemUiController = rememberSystemUiController()
val context = LocalContext.current
LaunchedEffect(AppState.darkMode) {
systemUiController.setStatusBarColor(Color.Transparent, !AppState.darkMode)
}
// 页面退出时清理消息相关资源
DisposableEffect(Unit) {
onDispose {
ResourceCleanupManager.cleanupPageResources("message")
}
}
Column(
modifier = Modifier
.fillMaxSize(),

View File

@@ -22,10 +22,15 @@ 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_ai) }
icon = { R.drawable.dynamic },
selectedIcon = { R.mipmap.dynamic_hl },
label = { stringResource(R.string.index_dynamic) }
)
// 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_ai) }
// )
data object Add : NavigationItem("Add",
icon = { R.drawable.ic_nav_add },

View File

@@ -30,9 +30,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
@@ -51,6 +48,12 @@ import com.aiosman.ravenow.ui.index.tabs.moment.tabs.timeline.TimelineMomentsLis
import com.aiosman.ravenow.ui.index.tabs.search.SearchViewModel
import com.aiosman.ravenow.ui.modifiers.noRippleClickable
import kotlinx.coroutines.launch
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.ColorFilter
import com.aiosman.ravenow.ui.composables.TabItem
import com.aiosman.ravenow.ui.composables.TabSpacer
import com.aiosman.ravenow.ui.composables.rememberDebouncer
/**
* 动态列表
@@ -63,8 +66,8 @@ fun MomentsList() {
val navigationBarPaddings =
WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding() + 48.dp
val statusBarPaddingValues = WindowInsets.systemBars.asPaddingValues()
// 游客模式下不显示timeline只显示3个tabExplore、Dynamic、Hot
val tabCount = if (AppStore.isGuest) 3 else 4
// 游客模式下不显示timeline只显示2个tabDynamic、Hot // 游客模式下不显示timeline只显示3个tabExplore、Dynamic、Hot
val tabCount = if (AppStore.isGuest) 2 else 3 // val tabCount = if (AppStore.isGuest) 3 else 4
var pagerState = rememberPagerState { tabCount }
var scope = rememberCoroutineScope()
Column(
@@ -79,154 +82,142 @@ fun MomentsList() {
Row(
modifier = Modifier
.fillMaxWidth()
.height(44.dp),
.height(44.dp)
.padding(horizontal = 16.dp),
// center the tabs
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.CenterVertically
) {
Column(
// Column(
// modifier = Modifier
// .noRippleClickable {
// scope.launch {
// pagerState.animateScrollToPage(0)
// }
// }.padding(start = 16.dp),
// verticalArrangement = Arrangement.Center,
// horizontalAlignment = Alignment.CenterHorizontally
//
// ) {
// Text(
// text = stringResource(R.string.index_worldwide),
// fontSize = if (pagerState.currentPage == 0)18.sp else 16.sp,
// color = if (pagerState.currentPage == 0) AppColors.text else AppColors.nonActiveText,
// fontWeight = FontWeight.W600)
// Spacer(modifier = Modifier.height(4.dp))
//
// Image(
// painter = painterResource(
// if (pagerState.currentPage == 0) R.mipmap.tab_indicator_selected
// else R.drawable.tab_indicator_unselected
// ),
// contentDescription = "tab indicator",
// modifier = Modifier
// .width(34.dp)
// .height(4.dp)
// )
//
// }
// Spacer(modifier = Modifier.width(16.dp))
Text(
text = stringResource(R.string.moment),
fontSize = 20.sp,
fontWeight = FontWeight.W900,
color = AppColors.text,
modifier = Modifier
.noRippleClickable {
scope.launch {
pagerState.animateScrollToPage(0)
}
}.padding(start = 16.dp),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
.align(Alignment.CenterVertically)
)
) {
Text(
text = stringResource(R.string.index_worldwide),
fontSize = if (pagerState.currentPage == 0)18.sp else 16.sp,
color = if (pagerState.currentPage == 0) AppColors.text else AppColors.nonActiveText,
fontWeight = FontWeight.W600)
Spacer(modifier = Modifier.height(4.dp))
Spacer(modifier = Modifier.weight(1f))
Image(
painter = painterResource(
if (pagerState.currentPage == 0) R.mipmap.tab_indicator_selected
else R.drawable.tab_indicator_unselected
),
contentDescription = "tab indicator",
modifier = Modifier
.width(34.dp)
.height(4.dp)
)
}
Spacer(modifier = Modifier.width(16.dp))
Column(
Image(
painter = painterResource(id = R.drawable.rider_pro_nav_search),
contentDescription = "search",
modifier = Modifier
.size(24.dp)
.noRippleClickable {
scope.launch {
pagerState.animateScrollToPage(1)
}
navController.navigate(NavigationRoute.Search.route)
},
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
colorFilter = ColorFilter.tint(AppColors.text)
)
}
Spacer(modifier = Modifier.height(23.dp))
Row(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(start = 16.dp, bottom = 16.dp),
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.Bottom
) {
val tabDebouncer = rememberDebouncer()
// 探索标签
Box {
CustomTabItem(
text = stringResource(R.string.index_dynamic),
fontSize = if (pagerState.currentPage == 1)18.sp else 16.sp,
color = if (pagerState.currentPage == 1) AppColors.text else AppColors.nonActiveText,
fontWeight = FontWeight.W600)
Spacer(modifier = Modifier.height(4.dp))
Image(
painter = painterResource(
if (pagerState.currentPage == 1) R.mipmap.tab_indicator_selected
else R.drawable.tab_indicator_unselected
),
contentDescription = "tab indicator",
modifier = Modifier
.width(34.dp)
.height(4.dp)
isSelected = pagerState.currentPage == 0,
onClick = {
tabDebouncer {
scope.launch {
pagerState.animateScrollToPage(0)
}
}
}
)
}
TabSpacer()
// 只有非游客用户才显示"关注"tab
if (!AppStore.isGuest) {
//关注tab
Spacer(modifier = Modifier.width(16.dp))
Column(
modifier = Modifier
.noRippleClickable {
scope.launch {
pagerState.animateScrollToPage(2)
}
},
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
Box {
CustomTabItem(
text = stringResource(R.string.index_following),
fontSize = if (pagerState.currentPage == 2)18.sp else 16.sp,
color = if (pagerState.currentPage == 2) AppColors.text else AppColors.nonActiveText,
fontWeight = FontWeight.W600)
Spacer(modifier = Modifier.height(4.dp))
Image(
painter = painterResource(
if (pagerState.currentPage == 2) R.mipmap.tab_indicator_selected
else R.drawable.tab_indicator_unselected
),
contentDescription = "tab indicator",
modifier = Modifier
.width(34.dp)
.height(4.dp)
isSelected = pagerState.currentPage == 1,
onClick = {
tabDebouncer {
scope.launch {
pagerState.animateScrollToPage(1)
}
}
}
)
}
}
//热门tab
Spacer(modifier = Modifier.width(16.dp))
Column(
modifier = Modifier
.noRippleClickable {
scope.launch {
val targetPage = if (AppStore.isGuest) 2 else 3
pagerState.animateScrollToPage(targetPage)
}
},
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
text = stringResource(R.string.index_hot),
fontSize = if ((AppStore.isGuest && pagerState.currentPage == 2) || (!AppStore.isGuest && pagerState.currentPage == 3)) 18.sp else 16.sp,
color = if ((AppStore.isGuest && pagerState.currentPage == 2) || (!AppStore.isGuest && pagerState.currentPage == 3)) AppColors.text else AppColors.nonActiveText,
fontWeight = FontWeight.W600)
Spacer(modifier = Modifier.height(4.dp))
Image(
painter = painterResource(
if ((AppStore.isGuest && pagerState.currentPage == 2) || (!AppStore.isGuest && pagerState.currentPage == 3)) R.mipmap.tab_indicator_selected
else R.drawable.tab_indicator_unselected
),
contentDescription = "tab indicator",
modifier = Modifier
.width(34.dp)
.height(4.dp)
)
TabSpacer()
}
//搜索按钮
Column(
modifier = Modifier
.padding(bottom = 8.dp, end = 16.dp)
.fillMaxWidth(),
horizontalAlignment = Alignment.End
) {
Icon(
ImageVector.vectorResource(R.drawable.rider_pro_nav_search),
contentDescription = "Clickable Icon",
tint = AppColors.text,
modifier = Modifier.size(24.dp)
.noRippleClickable {
navController.navigate(NavigationRoute.Search.route)
// 热门标签
Box {
CustomTabItem(
text = stringResource(R.string.index_hot),
isSelected = pagerState.currentPage == 2,
onClick = {
tabDebouncer {
scope.launch {
pagerState.animateScrollToPage(2)
}
}
}
)
)
}
} else {
// 热门标签 (游客模式)
Box {
CustomTabItem(
text = stringResource(R.string.index_hot),
isSelected = pagerState.currentPage == 1,
onClick = {
tabDebouncer {
scope.launch {
pagerState.animateScrollToPage(1)
}
}
}
)
}
}
}
@@ -237,31 +228,25 @@ fun MomentsList() {
.weight(1f)
) {
if (AppStore.isGuest) {
// 游客模式:Explore(0), Dynamic(1), Hot(2)
// 游客模式Dynamic(0), Hot(1)
when (it) {
0 -> {
Explore()
}
1 -> {
Dynamic()
}
2 -> {
1 -> {
HotMomentsList()
}
}
} else {
// 正常用户:Explore(0), Dynamic(1), Timeline(2), Hot(3)
// 正常用户Dynamic(0), Timeline(1), Hot(2)
when (it) {
0 -> {
Explore()
}
1 -> {
Dynamic()
}
2 -> {
1 -> {
TimelineMomentsList()
}
3 -> {
2 -> {
HotMomentsList()
}
}
@@ -269,5 +254,30 @@ fun MomentsList() {
}
}
}
@Composable
fun CustomTabItem(
text: String,
isSelected: Boolean,
onClick: () -> Unit,
modifier: Modifier = Modifier
) {
val AppColors = LocalAppTheme.current
Column(
modifier = modifier
.noRippleClickable { onClick() },
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
text = text,
fontSize = 15.sp,
color = if (isSelected) AppColors.tabSelectedText else AppColors.tabUnselectedText,
modifier = Modifier
.clip(RoundedCornerShape(10.dp))
.background(if (isSelected) AppColors.tabSelectedBackground else AppColors.tabUnselectedBackground)
.padding(horizontal = 11.dp, vertical = 4.dp)
)
}
}

View File

@@ -275,7 +275,7 @@ fun LoginPage() {
) {
Spacer(modifier = Modifier.weight(1f))
Image(
painter = painterResource(id = R.mipmap.rider_pro_color_logo_next),
painter = painterResource(id = R.mipmap.invalid_name),
contentDescription = "Rave Now",
modifier = Modifier
.size(52.dp)

View File

@@ -96,7 +96,7 @@ fun NewPostScreen() {
var isAiEnabled by remember { mutableStateOf(false) }
var isRotating by remember { mutableStateOf(false) }
var isRequesting by remember { mutableStateOf(false) }
val keyboardController = LocalSoftwareKeyboardController.current // 添加这行
val keyboardController = LocalSoftwareKeyboardController.current
val model = NewPostViewModel
val systemUiController = rememberSystemUiController()