|
|
|
@ -13,6 +13,7 @@ import androidx.compose.runtime.livedata.observeAsState |
|
|
|
|
import androidx.compose.ui.Alignment |
|
|
|
|
import androidx.compose.ui.Modifier |
|
|
|
|
import androidx.compose.ui.platform.LocalContext |
|
|
|
|
import androidx.compose.ui.res.stringResource |
|
|
|
|
import androidx.compose.ui.text.buildAnnotatedString |
|
|
|
|
import androidx.compose.ui.text.input.ImeAction |
|
|
|
|
import androidx.compose.ui.text.input.KeyboardType |
|
|
|
@ -23,13 +24,13 @@ import androidx.lifecycle.viewmodel.compose.viewModel |
|
|
|
|
import androidx.navigation.compose.NavHost |
|
|
|
|
import androidx.navigation.compose.composable |
|
|
|
|
import com.gyf.csams.BuildConfig |
|
|
|
|
import com.gyf.csams.R |
|
|
|
|
import com.gyf.csams.account.model.AccountViewModel |
|
|
|
|
import com.gyf.csams.account.model.DialogMessage |
|
|
|
|
import com.gyf.csams.uikit.AnimationText |
|
|
|
|
import com.gyf.lib.uikit.BaseTextField |
|
|
|
|
import com.gyf.lib.uikit.Body |
|
|
|
|
import com.gyf.lib.uikit.FormStatus |
|
|
|
|
import com.gyf.lib.uikit.ScaffoldModel |
|
|
|
|
import com.orhanobut.logger.Logger |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum class AccountRoute { |
|
|
|
@ -131,7 +132,6 @@ class AccountActivity : ComponentActivity() { |
|
|
|
|
route: AccountRoute, |
|
|
|
|
Action: @Composable (isValidForm: Boolean, accountViewModel: AccountViewModel, scaffoldModel: ScaffoldModel) -> Unit |
|
|
|
|
) { |
|
|
|
|
accountViewModel.scaffoldModel = scaffoldModel |
|
|
|
|
accountViewModel.route = route |
|
|
|
|
Row( |
|
|
|
|
horizontalArrangement = Arrangement.Center, |
|
|
|
@ -147,10 +147,10 @@ class AccountActivity : ComponentActivity() { |
|
|
|
|
append(accountViewModel.name.formValue.value ?: "") |
|
|
|
|
} |
|
|
|
|
withStyle(style = MaterialTheme.typography.subtitle1.toSpanStyle()) { |
|
|
|
|
append(accountViewModel.welcomeStart) |
|
|
|
|
append(stringResource(id = R.string.welcome_start)) |
|
|
|
|
} |
|
|
|
|
withStyle(style = MaterialTheme.typography.subtitle2.toSpanStyle()) { |
|
|
|
|
append(accountViewModel.welcomeEnd) |
|
|
|
|
append(stringResource(id = R.string.welcome_end)) |
|
|
|
|
} |
|
|
|
|
withStyle( |
|
|
|
|
style = MaterialTheme.typography.subtitle2.toSpanStyle() |
|
|
|
@ -188,20 +188,22 @@ class AccountActivity : ComponentActivity() { |
|
|
|
|
Column { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val isValidStudentId: Boolean by accountViewModel.isValidStudentId.observeAsState(false) |
|
|
|
|
val isValidStudentId by accountViewModel.studentId.statusForm.observeAsState() |
|
|
|
|
BaseTextField( |
|
|
|
|
form = accountViewModel.studentId, keyboardOptions = KeyboardOptions.Default.copy( |
|
|
|
|
keyboardType = KeyboardType.Number, |
|
|
|
|
imeAction = ImeAction.Done |
|
|
|
|
), isError = !isValidStudentId |
|
|
|
|
), isError = isValidStudentId != FormStatus.Valid |
|
|
|
|
) |
|
|
|
|
if (isValidStudentId) { |
|
|
|
|
if (checkRepeat) { |
|
|
|
|
val isRepeat: Boolean? by accountViewModel.isRepeat.observeAsState(null) |
|
|
|
|
Logger.i("isRepeat=$isRepeat") |
|
|
|
|
when (isRepeat) { |
|
|
|
|
null -> AnimationText(text = accountViewModel.checkRegTip) |
|
|
|
|
true -> |
|
|
|
|
|
|
|
|
|
when (isValidStudentId) { |
|
|
|
|
FormStatus.Empty, |
|
|
|
|
FormStatus.FormatError -> Text( |
|
|
|
|
text = stringResource(id = R.string.student_id_format), |
|
|
|
|
color = MaterialTheme.colors.error, |
|
|
|
|
style = MaterialTheme.typography.body1 |
|
|
|
|
) |
|
|
|
|
FormStatus.Repeat -> |
|
|
|
|
Text(buildAnnotatedString { |
|
|
|
|
append(accountViewModel.studentId.formDesc) |
|
|
|
|
withStyle( |
|
|
|
@ -213,28 +215,12 @@ class AccountActivity : ComponentActivity() { |
|
|
|
|
} |
|
|
|
|
append(accountViewModel.registered) |
|
|
|
|
}) |
|
|
|
|
false -> |
|
|
|
|
Text(buildAnnotatedString { |
|
|
|
|
append(accountViewModel.studentId.formDesc) |
|
|
|
|
withStyle( |
|
|
|
|
style = MaterialTheme.typography.body1.toSpanStyle().copy( |
|
|
|
|
color = MaterialTheme.colors.primary |
|
|
|
|
) |
|
|
|
|
) { |
|
|
|
|
append(accountViewModel.studentId.formValue.value ?: "") |
|
|
|
|
} |
|
|
|
|
append(accountViewModel.canRegister) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
else -> { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
Text( |
|
|
|
|
text = accountViewModel.studentIdFormat, |
|
|
|
|
color = MaterialTheme.colors.error, |
|
|
|
|
style = MaterialTheme.typography.body1 |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|