|
|
@ -19,7 +19,6 @@ import androidx.compose.ui.text.input.ImeAction |
|
|
|
import androidx.compose.ui.text.input.KeyboardType |
|
|
|
import androidx.compose.ui.text.input.KeyboardType |
|
|
|
import androidx.compose.ui.text.input.PasswordVisualTransformation |
|
|
|
import androidx.compose.ui.text.input.PasswordVisualTransformation |
|
|
|
import androidx.compose.ui.text.withStyle |
|
|
|
import androidx.compose.ui.text.withStyle |
|
|
|
import androidx.compose.ui.tooling.preview.Preview |
|
|
|
|
|
|
|
import androidx.compose.ui.unit.dp |
|
|
|
import androidx.compose.ui.unit.dp |
|
|
|
import androidx.lifecycle.viewmodel.compose.viewModel |
|
|
|
import androidx.lifecycle.viewmodel.compose.viewModel |
|
|
|
import androidx.navigation.compose.NavHost |
|
|
|
import androidx.navigation.compose.NavHost |
|
|
@ -117,21 +116,20 @@ class AccountActivity : ComponentActivity() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 帐号表单 |
|
|
|
* 帐号表单 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param accountViewModel |
|
|
|
* @param accountViewModel |
|
|
|
* @param Action 表单操作区域 |
|
|
|
* @param Action 表单操作区域 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
private fun Account( |
|
|
|
private fun Account( |
|
|
|
accountViewModel: AccountViewModel = viewModel(), |
|
|
|
accountViewModel: AccountViewModel = viewModel(), |
|
|
|
scaffoldState: ScaffoldState, |
|
|
|
scaffoldState: ScaffoldState, |
|
|
|
route: AccountRoute, |
|
|
|
route: AccountRoute, |
|
|
|
Action: @Composable (isValidForm: Boolean, accountViewModel: AccountViewModel) -> Unit |
|
|
|
Action: @Composable (isValidForm: Boolean, accountViewModel: AccountViewModel) -> Unit |
|
|
|
) { |
|
|
|
) { |
|
|
|
accountViewModel.route = route |
|
|
|
accountViewModel.route = route |
|
|
|
Row( |
|
|
|
Row( |
|
|
|
horizontalArrangement = Arrangement.Center, |
|
|
|
horizontalArrangement = Arrangement.Center, |
|
|
@ -185,14 +183,14 @@ private fun Account( |
|
|
|
RegisterDialog() |
|
|
|
RegisterDialog() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 学号 |
|
|
|
* 学号 |
|
|
|
* @param accountViewModel |
|
|
|
* @param accountViewModel |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
private fun StudentId(accountViewModel: AccountViewModel = viewModel(), checkRepeat: Boolean) { |
|
|
|
private fun StudentId(accountViewModel: AccountViewModel = viewModel(), checkRepeat: Boolean) { |
|
|
|
Column { |
|
|
|
Column { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -244,31 +242,31 @@ private fun StudentId(accountViewModel: AccountViewModel = viewModel(), checkRep |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 注册弹窗 |
|
|
|
* 注册弹窗 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param accountViewModel |
|
|
|
* @param accountViewModel |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
private fun RegisterDialog(accountViewModel: AccountViewModel = viewModel()) { |
|
|
|
private fun RegisterDialog(accountViewModel: AccountViewModel = viewModel()) { |
|
|
|
val dialogMsg: DialogMessage? by accountViewModel.dialogMsg.observeAsState(null) |
|
|
|
val dialogMsg: DialogMessage? by accountViewModel.dialogMsg.observeAsState(null) |
|
|
|
|
|
|
|
|
|
|
|
val message = dialogMsg?.userResDto?.password |
|
|
|
val message = dialogMsg?.userResDto?.password |
|
|
|
if (message?.isNotEmpty() == true) { |
|
|
|
if (message?.isNotEmpty() == true) { |
|
|
|
PasswordDialog(message = message) |
|
|
|
PasswordDialog(message = message) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 密码弹窗 |
|
|
|
* 密码弹窗 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param accountViewModel |
|
|
|
* @param accountViewModel |
|
|
|
* @param message |
|
|
|
* @param message |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
private fun PasswordDialog(accountViewModel: AccountViewModel = viewModel(), message: String) { |
|
|
|
private fun PasswordDialog(accountViewModel: AccountViewModel = viewModel(), message: String) { |
|
|
|
val context = LocalContext.current |
|
|
|
val context = LocalContext.current |
|
|
|
val button: @Composable () -> Unit = { |
|
|
|
val button: @Composable () -> Unit = { |
|
|
|
Row( |
|
|
|
Row( |
|
|
@ -309,15 +307,15 @@ private fun PasswordDialog(accountViewModel: AccountViewModel = viewModel(), mes |
|
|
|
append(accountViewModel.passwordDialogEnd) |
|
|
|
append(accountViewModel.passwordDialogEnd) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 姓名文本框 |
|
|
|
* 姓名文本框 |
|
|
|
* @param accountViewModel |
|
|
|
* @param accountViewModel |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
private fun Name(accountViewModel: AccountViewModel = viewModel()) { |
|
|
|
private fun Name(accountViewModel: AccountViewModel = viewModel()) { |
|
|
|
Column { |
|
|
|
Column { |
|
|
|
|
|
|
|
|
|
|
|
val isValidName: Boolean by accountViewModel.isValidName.observeAsState(false) |
|
|
|
val isValidName: Boolean by accountViewModel.isValidName.observeAsState(false) |
|
|
@ -331,14 +329,14 @@ private fun Name(accountViewModel: AccountViewModel = viewModel()) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 密码框 |
|
|
|
* 密码框 |
|
|
|
* @param accountViewModel |
|
|
|
* @param accountViewModel |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
private fun Password(accountViewModel: AccountViewModel = viewModel()) { |
|
|
|
private fun Password(accountViewModel: AccountViewModel = viewModel()) { |
|
|
|
Column { |
|
|
|
Column { |
|
|
|
val isValidPwd: Boolean by accountViewModel.isValidPwd.observeAsState(false) |
|
|
|
val isValidPwd: Boolean by accountViewModel.isValidPwd.observeAsState(false) |
|
|
|
|
|
|
|
|
|
|
@ -358,41 +356,23 @@ private fun Password(accountViewModel: AccountViewModel = viewModel()) { |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 提示自动生成密码 |
|
|
|
* 提示自动生成密码 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param accountViewModel |
|
|
|
* @param accountViewModel |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
private fun PasswordTip(accountViewModel: AccountViewModel = viewModel()) { |
|
|
|
private fun PasswordTip(accountViewModel: AccountViewModel = viewModel()) { |
|
|
|
if (accountViewModel.isValidForm.value == true) { |
|
|
|
if (accountViewModel.isValidForm.value == true) { |
|
|
|
Text( |
|
|
|
Text( |
|
|
|
text = accountViewModel.passwordTip, color = MaterialTheme.colors.primary, |
|
|
|
text = accountViewModel.passwordTip, color = MaterialTheme.colors.primary, |
|
|
|
modifier = Modifier.fillMaxWidth() |
|
|
|
modifier = Modifier.fillMaxWidth() |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Preview(showBackground = true) |
|
|
|
|
|
|
|
@Composable |
|
|
|
|
|
|
|
fun DefaultPreview() { |
|
|
|
|
|
|
|
CSAMSTheme { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Row( |
|
|
|
|
|
|
|
horizontalArrangement = Arrangement.Center, |
|
|
|
|
|
|
|
verticalAlignment = Alignment.CenterVertically, |
|
|
|
|
|
|
|
modifier = Modifier.fillMaxSize() |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
Column(modifier = Modifier.width(IntrinsicSize.Min)) { |
|
|
|
|
|
|
|
val model: AccountViewModel = viewModel() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StudentId(model, false) |
|
|
|
|
|
|
|
Spacer(modifier = Modifier.height(10.dp)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|