auth to server-V4
This commit is contained in:
parent
eeba3524fa
commit
299e4c2d1d
5 changed files with 30 additions and 7 deletions
|
|
@ -26,6 +26,8 @@ class MainActivity : ComponentActivity() {
|
|||
|
||||
installSplashScreen()
|
||||
setContent {
|
||||
|
||||
//theme mode data
|
||||
val currentAppTheme by themeViewModel.currentTheme.collectAsState()
|
||||
|
||||
Login_V3Theme(appTheme = currentAppTheme) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.example.login_v3.auth.reg
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
|
|
@ -27,7 +28,9 @@ import androidx.compose.ui.unit.dp
|
|||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
|
||||
@Composable
|
||||
fun RegisterScreen(viewModel: RegisterViewModel = hiltViewModel()) {
|
||||
fun RegisterScreen(
|
||||
viewModel: RegisterViewModel = hiltViewModel()
|
||||
) {
|
||||
// 監聽狀態
|
||||
val uiState by viewModel.uiState.collectAsState()
|
||||
|
||||
|
|
@ -48,9 +51,21 @@ fun RegisterScreen(viewModel: RegisterViewModel = hiltViewModel()) {
|
|||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
OutlinedTextField(value = displayName, onValueChange = { displayName = it }, label = { Text("顯示名稱") })
|
||||
OutlinedTextField(value = email, onValueChange = { email = it }, label = { Text("電子信箱") })
|
||||
OutlinedTextField(value = username, onValueChange = { username = it }, label = { Text("帳號") })
|
||||
OutlinedTextField(
|
||||
value = displayName,
|
||||
onValueChange = { displayName = it },
|
||||
label = { Text("顯示名稱") }
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = email,
|
||||
onValueChange = { email = it },
|
||||
label = { Text("電子信箱") }
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = username,
|
||||
onValueChange = { username = it },
|
||||
label = { Text("帳號") }
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = password,
|
||||
onValueChange = { password = it },
|
||||
|
|
@ -65,7 +80,9 @@ fun RegisterScreen(viewModel: RegisterViewModel = hiltViewModel()) {
|
|||
} else {
|
||||
Button(
|
||||
onClick = { viewModel.handleRegister(displayName, email, password, username) },
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.background(color = Color.Gray)
|
||||
) {
|
||||
Text("註冊")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.example.login_v3.data.api.api_class
|
||||
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
data class LoginRequest(
|
||||
val username: String,
|
||||
val password: String
|
||||
|
|
@ -10,6 +12,7 @@ data class LoginResponse(
|
|||
val userId: String
|
||||
)
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class RegisterRequest(
|
||||
val display_name: String,
|
||||
val email: String,
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ enum class AppScreen {
|
|||
}
|
||||
|
||||
class AppViewModel : ViewModel() {
|
||||
private val _currentScreen = MutableStateFlow<AppScreen>(AppScreen.ScreensTab)
|
||||
private val _currentScreen = MutableStateFlow<AppScreen>(AppScreen.PreReg)
|
||||
val currentScreen: StateFlow<AppScreen> = _currentScreen
|
||||
|
||||
fun goTo(screen: AppScreen) {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import androidx.compose.runtime.getValue
|
|||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.example.login_v3.auth.login.LoginScreen
|
||||
import com.example.login_v3.auth.Login_or_Reg_page
|
||||
import com.example.login_v3.auth.reg.RegisterScreen
|
||||
import com.example.login_v3.auth.reg.Register_Screen
|
||||
import com.example.login_v3.home.HomeScreen
|
||||
|
||||
|
|
@ -35,7 +36,7 @@ fun AppNavGraph(
|
|||
BackHandler {
|
||||
appViewModel.goTo(AppScreen.PreReg)
|
||||
}
|
||||
Register_Screen(paddingValues = paddingValues)
|
||||
RegisterScreen()
|
||||
}
|
||||
|
||||
AppScreen.Home -> HomeScreen(
|
||||
|
|
|
|||
Loading…
Reference in a new issue