更新代码

This commit is contained in:
2024-09-22 15:35:42 +08:00
parent fc7d9336cd
commit 573b85f35d
16 changed files with 133 additions and 91 deletions

View File

@@ -6,6 +6,8 @@ import android.app.NotificationManager
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.icu.util.Calendar
import android.icu.util.TimeZone
import android.net.Uri import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
@@ -28,6 +30,7 @@ import com.aiosman.riderpro.data.AccountService
import com.aiosman.riderpro.data.AccountServiceImpl import com.aiosman.riderpro.data.AccountServiceImpl
import com.aiosman.riderpro.ui.Navigation import com.aiosman.riderpro.ui.Navigation
import com.aiosman.riderpro.ui.NavigationRoute import com.aiosman.riderpro.ui.NavigationRoute
import com.aiosman.riderpro.ui.navigateToPost
import com.aiosman.riderpro.ui.post.NewPostViewModel import com.aiosman.riderpro.ui.post.NewPostViewModel
import com.aiosman.riderpro.utils.Utils import com.aiosman.riderpro.utils.Utils
import com.google.android.libraries.places.api.Places import com.google.android.libraries.places.api.Places
@@ -59,8 +62,14 @@ class MainActivity : ComponentActivity() {
val accountService: AccountService = AccountServiceImpl() val accountService: AccountService = AccountServiceImpl()
try { try {
val resp = accountService.getMyAccount() val resp = accountService.getMyAccount()
accountService.updateUserLanguage( val calendar: Calendar = Calendar.getInstance()
Utils.getCurrentLanguage() val tz: TimeZone = calendar.timeZone
val offsetInMillis: Int = tz.rawOffset
accountService.updateUserExtra(
Utils.getCurrentLanguage(),
// 时区偏移量单位是秒
offsetInMillis / 1000,
tz.displayName
) )
// 设置当前登录用户 ID // 设置当前登录用户 ID
AppState.UserId = resp.id AppState.UserId = resp.id
@@ -122,19 +131,20 @@ class MainActivity : ComponentActivity() {
navController.navigate(NavigationRoute.Followers.route) navController.navigate(NavigationRoute.Followers.route)
return@Navigation return@Navigation
} }
if (action == "followCount") {
navController.navigate(NavigationRoute.Followers.route)
return@Navigation
}
if (commentId == null) { if (commentId == null) {
commentId = "0" commentId = "0"
} }
if (postId != null) { if (postId != null) {
Log.d("MainActivity", "Navigation to Post$postId") Log.d("MainActivity", "Navigation to Post$postId")
navController.navigate( navController.navigateToPost(
NavigationRoute.Post.route id = postId.toInt(),
.replace( highlightCommentId = commentId.toInt(),
"{id}", initImagePagerIndex = 0
postId
)
.replace("{highlightCommentId}", commentId)
) )
} }
// 处理分享过来的图片 // 处理分享过来的图片

View File

@@ -352,9 +352,9 @@ interface AccountService {
suspend fun resetPassword(email: String) suspend fun resetPassword(email: String)
/** /**
* 更新用户语言 * 更新用户额外信息
*/ */
suspend fun updateUserLanguage(language: String) suspend fun updateUserExtra(language: String, timeOffset: Int, timezone: String)
} }
class AccountServiceImpl : AccountService { class AccountServiceImpl : AccountService {
@@ -486,8 +486,8 @@ class AccountServiceImpl : AccountService {
} }
} }
override suspend fun updateUserLanguage(language: String) { override suspend fun updateUserExtra(language: String, timeOffset: Int, timezone: String) {
ApiClient.api.updateUserLang(UpdateUserLangRequestBody(language)) ApiClient.api.updateUserExtra(UpdateUserLangRequestBody(language, timeOffset, timezone))
} }
} }

View File

@@ -101,6 +101,10 @@ data class ResetPasswordRequestBody(
data class UpdateUserLangRequestBody( data class UpdateUserLangRequestBody(
@SerializedName("language") @SerializedName("language")
val lang: String, val lang: String,
@SerializedName("timeOffset")
val timeOffset: Int,
@SerializedName("timezone")
val timezone: String,
) )
interface RiderProAPI { interface RiderProAPI {
@@ -291,8 +295,8 @@ interface RiderProAPI {
@Path("id") id: Int @Path("id") id: Int
): Response<DataContainer<Comment>> ): Response<DataContainer<Comment>>
@PATCH("account/my/lang") @PATCH("account/my/extra")
suspend fun updateUserLang( suspend fun updateUserExtra(
@Body body: UpdateUserLangRequestBody @Body body: UpdateUserLangRequestBody
): Response<Unit> ): Response<Unit>

View File

@@ -61,7 +61,7 @@ sealed class NavigationRoute(
data object LocationDetail : NavigationRoute("LocationDetail/{x}/{y}") data object LocationDetail : NavigationRoute("LocationDetail/{x}/{y}")
data object OfficialPhoto : NavigationRoute("OfficialPhoto") data object OfficialPhoto : NavigationRoute("OfficialPhoto")
data object OfficialPhotographer : NavigationRoute("OfficialPhotographer") data object OfficialPhotographer : NavigationRoute("OfficialPhotographer")
data object Post : NavigationRoute("Post/{id}/{highlightCommentId}") data object Post : NavigationRoute("Post/{id}/{highlightCommentId}/{initImagePagerIndex}")
data object ModificationList : NavigationRoute("ModificationList") data object ModificationList : NavigationRoute("ModificationList")
data object MyMessage : NavigationRoute("MyMessage") data object MyMessage : NavigationRoute("MyMessage")
data object Comments : NavigationRoute("Comments") data object Comments : NavigationRoute("Comments")
@@ -137,19 +137,23 @@ fun NavigationController(
route = NavigationRoute.Post.route, route = NavigationRoute.Post.route,
arguments = listOf( arguments = listOf(
navArgument("id") { type = NavType.StringType }, navArgument("id") { type = NavType.StringType },
navArgument("highlightCommentId") { type = NavType.IntType } navArgument("highlightCommentId") { type = NavType.IntType },
navArgument("initImagePagerIndex") { type = NavType.IntType }
), ),
) { backStackEntry -> ) { backStackEntry ->
CompositionLocalProvider( CompositionLocalProvider(
LocalAnimatedContentScope provides this, LocalAnimatedContentScope provides this,
) { ) {
val id = backStackEntry.arguments?.getString("id") val id = backStackEntry.arguments?.getString("id")
val highlightCommentId = backStackEntry.arguments?.getInt("highlightCommentId")?.let { val highlightCommentId =
backStackEntry.arguments?.getInt("highlightCommentId")?.let {
if (it == 0) null else it if (it == 0) null else it
} }
val initIndex = backStackEntry.arguments?.getInt("initImagePagerIndex")
PostScreen( PostScreen(
id!!, id!!,
highlightCommentId highlightCommentId,
initImagePagerIndex = initIndex
) )
} }
} }
@@ -365,3 +369,16 @@ fun Navigation(
} }
} }
} }
fun NavHostController.navigateToPost(
id: Int,
highlightCommentId: Int? = 0,
initImagePagerIndex: Int? = null
) {
navigate(
route = NavigationRoute.Post.route
.replace("{id}", id.toString())
.replace("{highlightCommentId}", highlightCommentId.toString())
.replace("{initImagePagerIndex}", initImagePagerIndex.toString())
)
}

View File

@@ -31,6 +31,7 @@ import com.aiosman.riderpro.ui.composables.CustomAsyncImage
import com.aiosman.riderpro.ui.composables.StatusBarSpacer import com.aiosman.riderpro.ui.composables.StatusBarSpacer
import com.aiosman.riderpro.ui.favourite.FavouriteListViewModel.refreshPager import com.aiosman.riderpro.ui.favourite.FavouriteListViewModel.refreshPager
import com.aiosman.riderpro.ui.modifiers.noRippleClickable import com.aiosman.riderpro.ui.modifiers.noRippleClickable
import com.aiosman.riderpro.ui.navigateToPost
@OptIn(ExperimentalMaterialApi::class) @OptIn(ExperimentalMaterialApi::class)
@Composable @Composable
@@ -79,11 +80,10 @@ fun FavouriteListPage() {
.padding(2.dp) .padding(2.dp)
.noRippleClickable { .noRippleClickable {
navController.navigate( navController.navigateToPost(
NavigationRoute.Post.route.replace( id = momentItem.id,
"{id}", highlightCommentId = 0,
momentItem.id.toString() initImagePagerIndex = 0
).replace("{highlightCommentId}", "0")
) )
} }
) { ) {

View File

@@ -7,12 +7,9 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
@@ -28,10 +25,6 @@ import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
@@ -51,14 +44,13 @@ import com.aiosman.riderpro.R
import com.aiosman.riderpro.entity.CommentEntity import com.aiosman.riderpro.entity.CommentEntity
import com.aiosman.riderpro.exp.timeAgo import com.aiosman.riderpro.exp.timeAgo
import com.aiosman.riderpro.ui.NavigationRoute import com.aiosman.riderpro.ui.NavigationRoute
import com.aiosman.riderpro.ui.composables.BottomNavigationPlaceholder
import com.aiosman.riderpro.ui.composables.CustomAsyncImage import com.aiosman.riderpro.ui.composables.CustomAsyncImage
import com.aiosman.riderpro.ui.composables.StatusBarSpacer import com.aiosman.riderpro.ui.composables.StatusBarSpacer
import com.aiosman.riderpro.ui.favourite.FavouriteNoticeViewModel import com.aiosman.riderpro.ui.favourite.FavouriteNoticeViewModel
import com.aiosman.riderpro.ui.follower.FollowerNoticeViewModel import com.aiosman.riderpro.ui.follower.FollowerNoticeViewModel
import com.aiosman.riderpro.ui.like.LikeNoticeViewModel import com.aiosman.riderpro.ui.like.LikeNoticeViewModel
import com.aiosman.riderpro.ui.modifiers.noRippleClickable import com.aiosman.riderpro.ui.modifiers.noRippleClickable
import com.aiosman.riderpro.ui.post.PostViewModel import com.aiosman.riderpro.ui.navigateToPost
import com.google.accompanist.systemuicontroller.rememberSystemUiController import com.google.accompanist.systemuicontroller.rememberSystemUiController
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@@ -179,14 +171,10 @@ fun NotificationsScreen() {
comment.parentCommentId?.let { comment.parentCommentId?.let {
highlightCommentId = it highlightCommentId = it
} }
navController.navigate( navController.navigateToPost(
NavigationRoute.Post.route.replace( id = comment.post!!.id,
"{id}", highlightCommentId = highlightCommentId,
comment.postId.toString() initImagePagerIndex = 0
).replace(
"{highlightCommentId}",
highlightCommentId.toString()
)
) )
} }
} }

View File

@@ -61,7 +61,6 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.paging.LoadState
import androidx.paging.compose.collectAsLazyPagingItems import androidx.paging.compose.collectAsLazyPagingItems
import com.aiosman.riderpro.LocalNavController import com.aiosman.riderpro.LocalNavController
import com.aiosman.riderpro.R import com.aiosman.riderpro.R
@@ -76,8 +75,8 @@ import com.aiosman.riderpro.ui.composables.AnimatedLikeIcon
import com.aiosman.riderpro.ui.composables.CustomAsyncImage import com.aiosman.riderpro.ui.composables.CustomAsyncImage
import com.aiosman.riderpro.ui.composables.RelPostCard import com.aiosman.riderpro.ui.composables.RelPostCard
import com.aiosman.riderpro.ui.modifiers.noRippleClickable import com.aiosman.riderpro.ui.modifiers.noRippleClickable
import com.aiosman.riderpro.ui.navigateToPost
import com.aiosman.riderpro.ui.post.NewPostViewModel import com.aiosman.riderpro.ui.post.NewPostViewModel
import com.aiosman.riderpro.ui.post.PostViewModel
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
/** /**
@@ -178,10 +177,10 @@ fun MomentCard(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.noRippleClickable { .noRippleClickable {
navController.navigate( navController.navigateToPost(
route = NavigationRoute.Post.route momentEntity.id,
.replace("{id}", momentEntity.id.toString()) highlightCommentId = 0,
.replace("{highlightCommentId}", "0") initImagePagerIndex = imageIndex
) )
} }
) { ) {
@@ -203,8 +202,11 @@ fun MomentCard(
onFavoriteClick = onFavoriteClick, onFavoriteClick = onFavoriteClick,
imageIndex = imageIndex, imageIndex = imageIndex,
onCommentClick = { onCommentClick = {
// PostViewModel.preTransit(momentEntity) navController.navigateToPost(
navController.navigate("Post/${momentEntity.id}") momentEntity.id,
highlightCommentId = 0,
initImagePagerIndex = imageIndex
)
} }
) )
} }

View File

@@ -33,7 +33,7 @@ object MomentViewModel : ViewModel() {
var refreshing by mutableStateOf(false) var refreshing by mutableStateOf(false)
var isFirstLoad = true var isFirstLoad = true
fun refreshPager(pullRefresh: Boolean = false) { fun refreshPager(pullRefresh: Boolean = false) {
if (!isFirstLoad) { if (!isFirstLoad && !pullRefresh) {
return return
} }
isFirstLoad = false isFirstLoad = false

View File

@@ -40,9 +40,9 @@ object MyProfileViewModel : ViewModel() {
var refreshing by mutableStateOf(false) var refreshing by mutableStateOf(false)
var firstLoad = true var firstLoad = true
fun loadProfile(pullRefresh: Boolean = false) { fun loadProfile(pullRefresh: Boolean = false) {
if (!firstLoad && !pullRefresh) { // if (!firstLoad && !pullRefresh) {
return // return
} // }
viewModelScope.launch { viewModelScope.launch {
if (pullRefresh){ if (pullRefresh){
refreshing = true refreshing = true

View File

@@ -78,6 +78,8 @@ import com.aiosman.riderpro.ui.NavigationRoute
import com.aiosman.riderpro.ui.composables.CustomAsyncImage import com.aiosman.riderpro.ui.composables.CustomAsyncImage
import com.aiosman.riderpro.ui.composables.MenuItem import com.aiosman.riderpro.ui.composables.MenuItem
import com.aiosman.riderpro.ui.modifiers.noRippleClickable import com.aiosman.riderpro.ui.modifiers.noRippleClickable
import com.aiosman.riderpro.ui.navigateToPost
import com.aiosman.riderpro.ui.post.NewPostViewModel
import com.aiosman.riderpro.ui.post.PostViewModel import com.aiosman.riderpro.ui.post.PostViewModel
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@@ -673,9 +675,9 @@ fun ProfileEmptyMomentCard(
.fillMaxSize() .fillMaxSize()
.background(Color(0xFFF5F5F5)) .background(Color(0xFFF5F5F5))
.noRippleClickable { .noRippleClickable {
NewPostViewModel.asNewPost()
navController.navigate(NavigationRoute.NewPost.route) navController.navigate(NavigationRoute.NewPost.route)
} }
) { ) {
Icon( Icon(
Icons.Default.Add, Icons.Default.Add,
@@ -808,12 +810,10 @@ fun MomentCardPicture(imageUrl: String, momentEntity: MomentEntity) {
.aspectRatio(3f / 2f) .aspectRatio(3f / 2f)
.padding(top = 16.dp) .padding(top = 16.dp)
.noRippleClickable { .noRippleClickable {
// PostViewModel.preTransit(momentEntity) navController.navigateToPost(
navController.navigate( id = momentEntity.id,
NavigationRoute.Post.route.replace( highlightCommentId = 0,
"{id}", initImagePagerIndex = 0
momentEntity.id.toString()
).replace("{highlightCommentId}", "0")
) )
}, },
contentDescription = "", contentDescription = "",

View File

@@ -6,17 +6,14 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.lazy.grid.GridCells import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
@@ -50,8 +47,7 @@ import com.aiosman.riderpro.ui.NavigationRoute
import com.aiosman.riderpro.ui.composables.CustomAsyncImage import com.aiosman.riderpro.ui.composables.CustomAsyncImage
import com.aiosman.riderpro.ui.composables.StatusBarSpacer import com.aiosman.riderpro.ui.composables.StatusBarSpacer
import com.aiosman.riderpro.ui.modifiers.noRippleClickable import com.aiosman.riderpro.ui.modifiers.noRippleClickable
import com.aiosman.riderpro.ui.post.PostViewModel import com.aiosman.riderpro.ui.navigateToPost
import com.google.accompanist.systemuicontroller.rememberSystemUiController
@OptIn(ExperimentalFoundationApi::class, ExperimentalMaterialApi::class) @OptIn(ExperimentalFoundationApi::class, ExperimentalMaterialApi::class)
@@ -156,12 +152,10 @@ fun DiscoverView() {
.padding(2.dp) .padding(2.dp)
.noRippleClickable { .noRippleClickable {
// PostViewModel.preTransit(momentItem) navController.navigateToPost(
navController.navigate( id = momentItem.id,
NavigationRoute.Post.route.replace( highlightCommentId = 0,
"{id}", initImagePagerIndex = 0
momentItem.id.toString()
).replace("{highlightCommentId}", "0")
) )
} }
) { ) {

View File

@@ -46,6 +46,7 @@ import com.aiosman.riderpro.ui.composables.CustomAsyncImage
import com.aiosman.riderpro.ui.composables.StatusBarMaskLayout import com.aiosman.riderpro.ui.composables.StatusBarMaskLayout
import com.aiosman.riderpro.ui.index.tabs.profile.MyProfileViewModel import com.aiosman.riderpro.ui.index.tabs.profile.MyProfileViewModel
import com.aiosman.riderpro.ui.modifiers.noRippleClickable import com.aiosman.riderpro.ui.modifiers.noRippleClickable
import com.aiosman.riderpro.ui.navigateToPost
import java.util.Date import java.util.Date
@Preview @Preview
@@ -154,11 +155,10 @@ fun ActionPostNoticeItem(
modifier = Modifier modifier = Modifier
.weight(1f) .weight(1f)
.noRippleClickable { .noRippleClickable {
navController.navigate( navController.navigateToPost(
NavigationRoute.Post.route.replace( id = postId,
"{id}", highlightCommentId = 0,
postId.toString() initImagePagerIndex = 0
).replace("{highlightCommentId}", "0")
) )
} }
) { ) {
@@ -192,11 +192,10 @@ fun LikeCommentNoticeItem(
Box( Box(
modifier = Modifier.padding(vertical = 16.dp).noRippleClickable { modifier = Modifier.padding(vertical = 16.dp).noRippleClickable {
item.comment?.postId.let { item.comment?.postId.let {
navController.navigate( navController.navigateToPost(
NavigationRoute.Post.route.replace( id = it ?: 0,
"{id}", highlightCommentId = item.comment?.id ?: 0,
it.toString() initImagePagerIndex = 0
).replace("{highlightCommentId}", "0")
) )
} }

View File

@@ -1,5 +1,7 @@
package com.aiosman.riderpro.ui.login package com.aiosman.riderpro.ui.login
import android.icu.util.Calendar
import android.icu.util.TimeZone
import android.widget.Toast import android.widget.Toast
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
@@ -156,8 +158,13 @@ fun EmailSignupScreen() {
try { try {
val resp = accountService.getMyAccount() val resp = accountService.getMyAccount()
AppState.UserId = resp.id AppState.UserId = resp.id
accountService.updateUserLanguage( val calendar: Calendar = Calendar.getInstance()
Utils.getCurrentLanguage() val tz: TimeZone = calendar.timeZone
val offsetInMillis: Int = tz.rawOffset
accountService.updateUserExtra(
Utils.getCurrentLanguage(),
offsetInMillis / 1000,
tz.displayName
) )
Messaging.RegistDevice(scope, context) Messaging.RegistDevice(scope, context)
} catch (e: ServiceException) { } catch (e: ServiceException) {

View File

@@ -1,6 +1,8 @@
package com.aiosman.riderpro.ui.login package com.aiosman.riderpro.ui.login
import android.content.ContentValues.TAG import android.content.ContentValues.TAG
import android.icu.util.Calendar
import android.icu.util.TimeZone
import android.util.Log import android.util.Log
import android.widget.Toast import android.widget.Toast
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
@@ -85,8 +87,13 @@ fun SignupScreen() {
// 获取token 信息 // 获取token 信息
try { try {
val resp = accountService.getMyAccount() val resp = accountService.getMyAccount()
accountService.updateUserLanguage( val calendar: Calendar = Calendar.getInstance()
Utils.getCurrentLanguage() val tz: TimeZone = calendar.timeZone
val offsetInMillis: Int = tz.rawOffset
accountService.updateUserExtra(
Utils.getCurrentLanguage(),
offsetInMillis / 1000,
tz.displayName
) )
AppState.UserId = resp.id AppState.UserId = resp.id
Messaging.RegistDevice(coroutineScope, context) Messaging.RegistDevice(coroutineScope, context)

View File

@@ -1,5 +1,7 @@
package com.aiosman.riderpro.ui.login package com.aiosman.riderpro.ui.login
import android.icu.util.Calendar
import android.icu.util.TimeZone
import android.widget.Toast import android.widget.Toast
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.background import androidx.compose.foundation.background
@@ -44,6 +46,7 @@ import com.aiosman.riderpro.ui.composables.StatusBarSpacer
import com.aiosman.riderpro.ui.composables.TextInputField import com.aiosman.riderpro.ui.composables.TextInputField
import com.aiosman.riderpro.ui.modifiers.noRippleClickable import com.aiosman.riderpro.ui.modifiers.noRippleClickable
import com.aiosman.riderpro.utils.GoogleLogin import com.aiosman.riderpro.utils.GoogleLogin
import com.aiosman.riderpro.utils.Utils
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@@ -81,6 +84,14 @@ fun UserAuthScreen() {
saveData() saveData()
} }
accountService.getMyAccount() accountService.getMyAccount()
val calendar: Calendar = Calendar.getInstance()
val tz: TimeZone = calendar.timeZone
val offsetInMillis: Int = tz.rawOffset
accountService.updateUserExtra(
Utils.getCurrentLanguage(),
offsetInMillis / 1000,
tz.displayName
)
Messaging.RegistDevice(scope, context) Messaging.RegistDevice(scope, context)
navController.navigate(NavigationRoute.Index.route) { navController.navigate(NavigationRoute.Index.route) {
popUpTo(NavigationRoute.Login.route) { inclusive = true } popUpTo(NavigationRoute.Login.route) { inclusive = true }

View File

@@ -100,7 +100,8 @@ import kotlinx.coroutines.launch
@Composable @Composable
fun PostScreen( fun PostScreen(
id: String, id: String,
highlightCommentId: Int? highlightCommentId: Int?,
initImagePagerIndex: Int?
) { ) {
val viewModel = viewModel<PostViewModel>( val viewModel = viewModel<PostViewModel>(
key = "PostViewModel_$id", key = "PostViewModel_$id",
@@ -331,7 +332,8 @@ fun PostScreen(
.aspectRatio(383f / 527f) .aspectRatio(383f / 527f)
) { ) {
PostImageView( PostImageView(
viewModel.moment?.images ?: emptyList() viewModel.moment?.images ?: emptyList(),
initialPage = initImagePagerIndex
) )
} }
@@ -719,8 +721,9 @@ fun Header(
@Composable @Composable
fun PostImageView( fun PostImageView(
images: List<MomentImageEntity>, images: List<MomentImageEntity>,
initialPage: Int? = 0
) { ) {
val pagerState = rememberPagerState(pageCount = { images.size }) val pagerState = rememberPagerState(pageCount = { images.size }, initialPage = initialPage ?: 0)
val navController = LocalNavController.current val navController = LocalNavController.current
val sharedTransitionScope = LocalSharedTransitionScope.current val sharedTransitionScope = LocalSharedTransitionScope.current
val animatedVisibilityScope = LocalAnimatedContentScope.current val animatedVisibilityScope = LocalAnimatedContentScope.current