auth to server-V64
This commit is contained in:
parent
6ceda89f04
commit
67528b29cb
5 changed files with 29 additions and 9 deletions
|
|
@ -12,6 +12,7 @@ import androidx.compose.material3.ListItem
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.DisposableEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
|
@ -26,13 +27,22 @@ import coil.compose.AsyncImage
|
||||||
import com.example.login_v3.R
|
import com.example.login_v3.R
|
||||||
import com.example.login_v3.data.api.api_class.Friend
|
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.home.Message.ViewModel.Detail.ContactListViewModel
|
||||||
|
import com.example.login_v3.navigation.BottomBarViewModel
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Message_contact_list(
|
fun Message_contact_list(
|
||||||
navController: NavController,
|
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(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.draw.blur
|
import androidx.compose.ui.draw.blur
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import androidx.navigation.compose.NavHost
|
import androidx.navigation.compose.NavHost
|
||||||
import androidx.navigation.compose.composable
|
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.Message_contact_list
|
||||||
import com.example.login_v3.home.Message.UI.Detail.Scan_QRcode
|
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.home.Message.ViewModel.MessageViewModel
|
||||||
|
import com.example.login_v3.navigation.BottomBarViewModel
|
||||||
|
|
||||||
|
|
||||||
sealed class Screen(val route: String) {
|
sealed class Screen(val route: String) {
|
||||||
|
|
@ -67,7 +69,9 @@ sealed class Screen(val route: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Tg_Message() {
|
fun Tg_Message(
|
||||||
|
bottomBarViewModel: BottomBarViewModel = hiltViewModel()
|
||||||
|
) {
|
||||||
val navController = rememberNavController()
|
val navController = rememberNavController()
|
||||||
|
|
||||||
NavHost(navController = navController, startDestination = Screen.Messages.route) {
|
NavHost(navController = navController, startDestination = Screen.Messages.route) {
|
||||||
|
|
@ -83,7 +87,10 @@ fun Tg_Message() {
|
||||||
|
|
||||||
// 好友列表頁面
|
// 好友列表頁面
|
||||||
composable(Screen.FriendsList.route) {
|
composable(Screen.FriendsList.route) {
|
||||||
Message_contact_list(navController)
|
Message_contact_list(
|
||||||
|
navController,
|
||||||
|
bottomBarViewModel = bottomBarViewModel
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
//QR code
|
//QR code
|
||||||
|
|
@ -147,7 +154,7 @@ fun Loaded_Tg_Message(
|
||||||
text = { Text("新建聯絡") },
|
text = { Text("新建聯絡") },
|
||||||
onClick = {
|
onClick = {
|
||||||
expanded = false
|
expanded = false
|
||||||
navController.navigate(Screen.FriendsList.route)
|
navController.navigate(Screen.CreateContact.route)
|
||||||
},
|
},
|
||||||
colors = itemColors,
|
colors = itemColors,
|
||||||
leadingIcon = { Icon(Icons.Default.Create, contentDescription = null) }
|
leadingIcon = { Icon(Icons.Default.Create, contentDescription = null) }
|
||||||
|
|
@ -156,7 +163,7 @@ fun Loaded_Tg_Message(
|
||||||
text = { Text("好友列表") },
|
text = { Text("好友列表") },
|
||||||
onClick = {
|
onClick = {
|
||||||
expanded = false
|
expanded = false
|
||||||
navController.navigate(Screen.CreateContact.route)
|
navController.navigate(Screen.FriendsList.route)
|
||||||
},
|
},
|
||||||
colors = itemColors,
|
colors = itemColors,
|
||||||
leadingIcon = { Icon(Icons.Default.Person, contentDescription = null) }
|
leadingIcon = { Icon(Icons.Default.Person, contentDescription = null) }
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ fun SharedTransitionScope.setting_detail_Screen(
|
||||||
title: String,
|
title: String,
|
||||||
settingIcon: String,
|
settingIcon: String,
|
||||||
animatedVisibilityScope: AnimatedVisibilityScope,
|
animatedVisibilityScope: AnimatedVisibilityScope,
|
||||||
bottomBarViewModel: BottomBarViewModel
|
bottomBarViewModel: BottomBarViewModel = hiltViewModel()
|
||||||
){
|
){
|
||||||
//control bottom bar behavior
|
//control bottom bar behavior
|
||||||
DisposableEffect(Unit) {
|
DisposableEffect(Unit) {
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ fun SharedTransitionScope.setting_list_Screen(
|
||||||
Spacer(modifier = Modifier.width(8.dp))
|
Spacer(modifier = Modifier.width(8.dp))
|
||||||
Column {
|
Column {
|
||||||
Text(
|
Text(
|
||||||
text = "${item.title}",
|
text = " ${item.title}",
|
||||||
style = MaterialTheme.typography.titleMedium,
|
style = MaterialTheme.typography.titleMedium,
|
||||||
fontSize = 24.sp,
|
fontSize = 24.sp,
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
package com.example.login_v3.navigation
|
package com.example.login_v3.navigation
|
||||||
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
||||||
class ScreensViewModel : ViewModel() {
|
class ScreensViewModel : ViewModel() {
|
||||||
|
|
@ -15,7 +17,8 @@ class ScreensViewModel : ViewModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// BottomBarViewModel 放在同一個檔案,但仍是獨立的 ViewModel 類別
|
// BottomBarViewModel 放在同一個檔案,但仍是獨立的 ViewModel 類別
|
||||||
class BottomBarViewModel : ViewModel() {
|
@HiltViewModel
|
||||||
|
class BottomBarViewModel @Inject constructor () : ViewModel() {
|
||||||
private val _showBottomBar = MutableStateFlow(true)
|
private val _showBottomBar = MutableStateFlow(true)
|
||||||
val showBottomBar: StateFlow<Boolean> = _showBottomBar
|
val showBottomBar: StateFlow<Boolean> = _showBottomBar
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue