更新功能
- 新增多语言支持 - 优化时间显示 - 调整UI细节
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package com.aiosman.riderpro.exp
|
||||
|
||||
import android.content.Context
|
||||
import android.icu.text.SimpleDateFormat
|
||||
import android.icu.util.Calendar
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.aiosman.riderpro.R
|
||||
import com.aiosman.riderpro.data.api.ApiClient
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
@@ -9,7 +12,7 @@ import java.util.Locale
|
||||
/**
|
||||
* 格式化时间为 xx 前
|
||||
*/
|
||||
fun Date.timeAgo(): String {
|
||||
fun Date.timeAgo(context: Context): String {
|
||||
val now = Date()
|
||||
val diffInMillis = now.time - this.time
|
||||
|
||||
@@ -20,11 +23,11 @@ fun Date.timeAgo(): String {
|
||||
val years = days / 365
|
||||
|
||||
return when {
|
||||
seconds < 60 -> "$seconds seconds ago"
|
||||
minutes < 60 -> "$minutes minutes ago"
|
||||
hours < 24 -> "$hours hours ago"
|
||||
days < 365 -> "$days days ago"
|
||||
else -> "$years years ago"
|
||||
seconds < 60 -> context.getString(R.string.second_ago, seconds)
|
||||
minutes < 60 -> context.getString(R.string.minute_ago, minutes)
|
||||
hours < 24 -> context.getString(R.string.hour_ago, hours)
|
||||
days < 365 -> context.getString(R.string.days_ago, days)
|
||||
else -> SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(this)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -50,12 +51,10 @@ import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
*/
|
||||
@Composable
|
||||
fun NotificationsScreen() {
|
||||
val model = MessageListViewModel
|
||||
val navController = LocalNavController.current
|
||||
val systemUiController = rememberSystemUiController()
|
||||
var dataFlow = MessageListViewModel.commentItemsFlow
|
||||
var comments = dataFlow.collectAsLazyPagingItems()
|
||||
val statusBarPaddingValues = WindowInsets.systemBars.asPaddingValues()
|
||||
val navigationBarPaddings =
|
||||
WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding() + 48.dp
|
||||
LaunchedEffect(Unit) {
|
||||
@@ -68,7 +67,6 @@ fun NotificationsScreen() {
|
||||
) {
|
||||
Spacer(
|
||||
modifier = Modifier.padding(
|
||||
// top = statusBarPaddingValues.calculateTopPadding(),
|
||||
bottom = navigationBarPaddings
|
||||
)
|
||||
)
|
||||
@@ -92,21 +90,21 @@ fun NotificationsScreen() {
|
||||
NotificationIndicator(
|
||||
MessageListViewModel.likeNoticeCount,
|
||||
R.drawable.rider_pro_like,
|
||||
"LIKE"
|
||||
stringResource(R.string.like_upper)
|
||||
) {
|
||||
navController.navigate(NavigationRoute.Likes.route)
|
||||
}
|
||||
NotificationIndicator(
|
||||
MessageListViewModel.followNoticeCount,
|
||||
R.drawable.rider_pro_followers,
|
||||
"FOLLOWERS"
|
||||
stringResource(R.string.followers_upper)
|
||||
) {
|
||||
navController.navigate(NavigationRoute.Followers.route)
|
||||
}
|
||||
NotificationIndicator(
|
||||
MessageListViewModel.favouriteNoticeCount,
|
||||
R.drawable.rider_pro_favoriate,
|
||||
"Favourites"
|
||||
stringResource(R.string.favourites_upper)
|
||||
) {
|
||||
navController.navigate(NavigationRoute.FavouritesScreen.route)
|
||||
}
|
||||
@@ -217,7 +215,7 @@ fun NotificationCounterItem(count: Int) {
|
||||
|
||||
}
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
Text("NOTIFICATIONS", fontSize = 18.sp)
|
||||
Text(stringResource(R.string.notifications_upper), fontSize = 18.sp)
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
if (count > 0) {
|
||||
Box(
|
||||
@@ -314,7 +312,7 @@ fun CommentItem(
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
}
|
||||
Text(
|
||||
text = commentItem.date.timeAgo(),
|
||||
text = commentItem.date.timeAgo(context),
|
||||
fontSize = 14.sp,
|
||||
color = Color(0x66000000)
|
||||
)
|
||||
|
||||
@@ -344,7 +344,7 @@ fun MomentTopRowGroup(momentEntity: MomentEntity) {
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
MomentPostLocation(momentEntity.location)
|
||||
MomentPostTime(momentEntity.time.timeAgo())
|
||||
MomentPostTime(momentEntity.time.timeAgo(context))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
@@ -77,15 +78,12 @@ fun ProfilePage() {
|
||||
val model = MyProfileViewModel
|
||||
var expanded by remember { mutableStateOf(false) }
|
||||
LaunchedEffect(Unit) {
|
||||
Log.d("ProfilePage", "loadProfile")
|
||||
model.loadProfile()
|
||||
}
|
||||
val moments = model.momentsFlow.collectAsLazyPagingItems()
|
||||
val navController: NavController = LocalNavController.current
|
||||
val scope = rememberCoroutineScope()
|
||||
val statusBarPaddingValues = WindowInsets.systemBars.asPaddingValues()
|
||||
val navigationBarPaddings =
|
||||
WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding() + 48.dp
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
.fillMaxSize().padding(bottom = with(LocalDensity.current) {
|
||||
@@ -282,7 +280,7 @@ fun UserInformationFollowers(modifier: Modifier, accountProfileEntity: AccountPr
|
||||
)
|
||||
Text(
|
||||
modifier = Modifier.padding(top = 5.dp),
|
||||
text = "FOLLOWERS",
|
||||
text = stringResource(R.string.followers_upper),
|
||||
fontSize = 12.sp,
|
||||
color = Color.Black,
|
||||
style = TextStyle(fontWeight = FontWeight.Bold)
|
||||
@@ -363,7 +361,7 @@ fun UserInformationFollowing(modifier: Modifier, accountProfileEntity: AccountPr
|
||||
)
|
||||
Text(
|
||||
modifier = Modifier.padding(top = 5.dp),
|
||||
text = "FOLLOWING",
|
||||
text = stringResource(R.string.following_upper),
|
||||
fontSize = 12.sp,
|
||||
color = Color.Black,
|
||||
style = TextStyle(fontWeight = FontWeight.Bold)
|
||||
@@ -485,20 +483,6 @@ fun RidingStyleItem(styleContent: String) {
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun UserMoment(scope: LazyListScope) {
|
||||
|
||||
|
||||
// LazyColumn(
|
||||
// modifier = Modifier
|
||||
// .fillMaxWidth()
|
||||
// .weight(1f)
|
||||
// ){
|
||||
//
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun MomentPostUnit(momentEntity: MomentEntity) {
|
||||
TimeGroup(momentEntity.time.formatPostTime())
|
||||
|
||||
@@ -66,7 +66,6 @@ import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
fun DiscoverScreen() {
|
||||
val model = DiscoverViewModel
|
||||
val navController = LocalNavController.current
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
val systemUiController = rememberSystemUiController()
|
||||
val statusBarPaddingValues = WindowInsets.systemBars.asPaddingValues()
|
||||
val navigationBarPaddings =
|
||||
@@ -93,7 +92,7 @@ fun DiscoverScreen() {
|
||||
.fillMaxWidth()
|
||||
.padding(top = 16.dp, start = 24.dp, end = 24.dp),
|
||||
) {
|
||||
navController.navigate("Search")
|
||||
navController.navigate(NavigationRoute.Search.route)
|
||||
}
|
||||
Box(
|
||||
modifier = Modifier
|
||||
@@ -112,6 +111,7 @@ fun SearchButton(
|
||||
modifier: Modifier = Modifier,
|
||||
clickAction: () -> Unit = {}
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
Box(
|
||||
modifier = modifier
|
||||
.clip(shape = RoundedCornerShape(8.dp))
|
||||
@@ -131,7 +131,7 @@ fun SearchButton(
|
||||
)
|
||||
Box {
|
||||
Text(
|
||||
text = "Search",
|
||||
text = context.getString(R.string.search),
|
||||
modifier = Modifier.padding(start = 8.dp),
|
||||
color = Color(0xFF9E9E9E),
|
||||
fontSize = 18.sp
|
||||
|
||||
@@ -51,6 +51,7 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import com.aiosman.riderpro.LocalNavController
|
||||
import com.aiosman.riderpro.R
|
||||
import com.aiosman.riderpro.entity.AccountProfileEntity
|
||||
import com.aiosman.riderpro.ui.composables.CustomAsyncImage
|
||||
import com.aiosman.riderpro.ui.index.tabs.moment.MomentCard
|
||||
@@ -63,8 +64,9 @@ import kotlinx.coroutines.launch
|
||||
@Preview
|
||||
@Composable
|
||||
fun SearchScreen() {
|
||||
val context = LocalContext.current
|
||||
val model = SearchViewModel
|
||||
val categories = listOf("Moment", "User")
|
||||
val categories = listOf(context.getString(R.string.moment), context.getString(R.string.users))
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
val pagerState = rememberPagerState(pageCount = { categories.size })
|
||||
val selectedTabIndex = remember { derivedStateOf { pagerState.currentPage } }
|
||||
@@ -139,6 +141,7 @@ fun SearchInput(
|
||||
onSearch: () -> Unit = {},
|
||||
focusRequester: FocusRequester = remember { FocusRequester() }
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
Box(
|
||||
modifier = modifier
|
||||
.clip(shape = RoundedCornerShape(8.dp))
|
||||
@@ -156,7 +159,7 @@ fun SearchInput(
|
||||
Box {
|
||||
if (text.isEmpty()) {
|
||||
Text(
|
||||
text = "Search",
|
||||
text = context.getString(R.string.search),
|
||||
modifier = Modifier.padding(start = 8.dp),
|
||||
color = Color(0xFF9E9E9E),
|
||||
fontSize = 18.sp
|
||||
|
||||
@@ -146,7 +146,7 @@ fun ActionNoticeItem(
|
||||
Text(nickName, fontWeight = FontWeight.Bold, fontSize = 16.sp)
|
||||
Spacer(modifier = Modifier.height(5.dp))
|
||||
Row {
|
||||
Text(likeTime.timeAgo(), fontSize = 12.sp, color = Color(0x99000000))
|
||||
Text(likeTime.timeAgo(context), fontSize = 12.sp, color = Color(0x99000000))
|
||||
}
|
||||
}
|
||||
CustomAsyncImage(
|
||||
|
||||
@@ -600,7 +600,7 @@ fun CommentItem(commentEntity: CommentEntity, onLike: () -> Unit = {}) {
|
||||
) {
|
||||
Text(text = commentEntity.name, fontWeight = FontWeight.Bold)
|
||||
Text(text = commentEntity.comment)
|
||||
Text(text = commentEntity.date.timeAgo(), fontSize = 12.sp, color = Color.Gray)
|
||||
Text(text = commentEntity.date.timeAgo(context), fontSize = 12.sp, color = Color.Gray)
|
||||
}
|
||||
Column(
|
||||
modifier = Modifier.width(64.dp),
|
||||
|
||||
18
app/src/main/res/values-zh/strings.xml
Normal file
18
app/src/main/res/values-zh/strings.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">RiderPro</string>
|
||||
<string name="worldwide">世界</string>
|
||||
<string name="minute_ago">%1d分钟前</string>
|
||||
<string name="second_ago">%1d秒前</string>
|
||||
<string name="days_ago">%1d天前</string>
|
||||
<string name="hour_ago">%1d小时前</string>
|
||||
<string name="year_ago">%1d年前</string>
|
||||
<string name="search">搜索</string>
|
||||
<string name="moment">动态</string>
|
||||
<string name="users">用户</string>
|
||||
<string name="like_upper">点赞</string>
|
||||
<string name="followers_upper">关注者</string>
|
||||
<string name="favourites_upper">收藏</string>
|
||||
<string name="notifications_upper">消息</string>
|
||||
<string name="following_upper">关注中</string>
|
||||
</resources>
|
||||
@@ -1,3 +1,17 @@
|
||||
<resources>
|
||||
<string name="app_name">RiderPro</string>
|
||||
<string name="worldwide">Worldwide</string>
|
||||
<string name="minute_ago">%1d minute ago</string>
|
||||
<string name="second_ago">%1d second ago</string>
|
||||
<string name="days_ago">%1d days ago</string>
|
||||
<string name="hour_ago">%1d hour ago</string>
|
||||
<string name="year_ago">%1d year ago</string>
|
||||
<string name="search">Search</string>
|
||||
<string name="moment">Moment</string>
|
||||
<string name="users">Users</string>
|
||||
<string name="like_upper">LIKE</string>
|
||||
<string name="followers_upper">FOLLOWERS</string>
|
||||
<string name="favourites_upper">FAVOURITES</string>
|
||||
<string name="notifications_upper">NOTIFICATIONS</string>
|
||||
<string name="following_upper">FOLLOWING</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user