auth to server-V64

This commit is contained in:
Eric85710 2026-05-06 17:27:28 +08:00
parent 6ceda89f04
commit 67528b29cb
5 changed files with 29 additions and 9 deletions

View file

@ -12,6 +12,7 @@ import androidx.compose.material3.ListItem
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -26,13 +27,22 @@ import coil.compose.AsyncImage
import com.example.login_v3.R
import com.example.login_v3.data.api.api_class.Friend
import com.example.login_v3.home.Message.ViewModel.Detail.ContactListViewModel
import com.example.login_v3.navigation.BottomBarViewModel
@Composable
fun Message_contact_list(
navController: NavController,
viewModel: ContactListViewModel = hiltViewModel()
contactListViewModel: ContactListViewModel = hiltViewModel(),
bottomBarViewModel: BottomBarViewModel
){
val friends by viewModel.friends.collectAsStateWithLifecycle()
val friends by contactListViewModel.friends.collectAsStateWithLifecycle()
DisposableEffect(Unit) {
bottomBarViewModel.setVisible(false)
onDispose {
bottomBarViewModel.setVisible(true)
}
}
Column(
modifier = Modifier

View file

@ -49,6 +49,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.draw.blur
import androidx.compose.ui.draw.clip
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
@ -57,6 +58,7 @@ import com.example.login_v3.home.Message.UI.Detail.Message_add_contact
import com.example.login_v3.home.Message.UI.Detail.Message_contact_list
import com.example.login_v3.home.Message.UI.Detail.Scan_QRcode
import com.example.login_v3.home.Message.ViewModel.MessageViewModel
import com.example.login_v3.navigation.BottomBarViewModel
sealed class Screen(val route: String) {
@ -67,7 +69,9 @@ sealed class Screen(val route: String) {
}
@Composable
fun Tg_Message() {
fun Tg_Message(
bottomBarViewModel: BottomBarViewModel = hiltViewModel()
) {
val navController = rememberNavController()
NavHost(navController = navController, startDestination = Screen.Messages.route) {
@ -83,7 +87,10 @@ fun Tg_Message() {
// 好友列表頁面
composable(Screen.FriendsList.route) {
Message_contact_list(navController)
Message_contact_list(
navController,
bottomBarViewModel = bottomBarViewModel
)
}
//QR code
@ -147,7 +154,7 @@ fun Loaded_Tg_Message(
text = { Text("新建聯絡") },
onClick = {
expanded = false
navController.navigate(Screen.FriendsList.route)
navController.navigate(Screen.CreateContact.route)
},
colors = itemColors,
leadingIcon = { Icon(Icons.Default.Create, contentDescription = null) }
@ -156,7 +163,7 @@ fun Loaded_Tg_Message(
text = { Text("好友列表") },
onClick = {
expanded = false
navController.navigate(Screen.CreateContact.route)
navController.navigate(Screen.FriendsList.route)
},
colors = itemColors,
leadingIcon = { Icon(Icons.Default.Person, contentDescription = null) }

View file

@ -50,7 +50,7 @@ fun SharedTransitionScope.setting_detail_Screen(
title: String,
settingIcon: String,
animatedVisibilityScope: AnimatedVisibilityScope,
bottomBarViewModel: BottomBarViewModel
bottomBarViewModel: BottomBarViewModel = hiltViewModel()
){
//control bottom bar behavior
DisposableEffect(Unit) {

View file

@ -134,7 +134,7 @@ fun SharedTransitionScope.setting_list_Screen(
Spacer(modifier = Modifier.width(8.dp))
Column {
Text(
text = "${item.title}",
text = " ${item.title}",
style = MaterialTheme.typography.titleMedium,
fontSize = 24.sp,
fontWeight = FontWeight.Bold,

View file

@ -1,8 +1,10 @@
package com.example.login_v3.navigation
import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import javax.inject.Inject
class ScreensViewModel : ViewModel() {
@ -15,7 +17,8 @@ class ScreensViewModel : ViewModel() {
}
// BottomBarViewModel 放在同一個檔案,但仍是獨立的 ViewModel 類別
class BottomBarViewModel : ViewModel() {
@HiltViewModel
class BottomBarViewModel @Inject constructor () : ViewModel() {
private val _showBottomBar = MutableStateFlow(true)
val showBottomBar: StateFlow<Boolean> = _showBottomBar