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