From bf48ccdb82bd796e2c2c933040bac22efe845630 Mon Sep 17 00:00:00 2001 From: zhong <2724770085@qq.com> Date: Wed, 12 Nov 2025 18:14:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=8D=20=E9=80=BB=E8=BE=91=EF=BC=9A?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=BE=E7=89=87=E5=8F=AF=E5=8F=91=E5=B8=83?= =?UTF-8?q?=EF=BC=8C=E5=8F=AA=E6=9C=89=E6=96=87=E5=AD=97=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ravenow/ui/composables/TextInputField.kt | 17 ++++++++-- .../com/aiosman/ravenow/ui/login/userauth.kt | 34 ++++++++++++------- .../com/aiosman/ravenow/ui/post/NewPost.kt | 2 +- .../ravenow/ui/post/NewPostViewModel.kt | 5 +-- 4 files changed, 39 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/aiosman/ravenow/ui/composables/TextInputField.kt b/app/src/main/java/com/aiosman/ravenow/ui/composables/TextInputField.kt index 3b4df82..26e2219 100644 --- a/app/src/main/java/com/aiosman/ravenow/ui/composables/TextInputField.kt +++ b/app/src/main/java/com/aiosman/ravenow/ui/composables/TextInputField.kt @@ -39,6 +39,7 @@ import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.text.input.VisualTransformation import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import com.aiosman.ravenow.AppState import com.aiosman.ravenow.LocalAppTheme import com.aiosman.ravenow.R import com.aiosman.ravenow.ui.modifiers.noRippleClickable @@ -59,17 +60,21 @@ fun TextInputField( enabled: Boolean = true, leadingIcon: @Composable (() -> Unit)? = null, customBackgroundColor: Color? = null, + customHintColor: Color? = null, + customLabelColor: Color? = null, customCornerRadius: Float = 24f ) { val AppColors = LocalAppTheme.current var showPassword by remember { mutableStateOf(!password) } var isFocused by remember { mutableStateOf(false) } val backgroundColor = customBackgroundColor ?: AppColors.inputBackground + val hintColor = customHintColor ?: HintTextColor + val labelColor = customLabelColor ?: LabelTextColor Column(modifier = modifier) { label?.let { Text( text = it, - color = LabelTextColor, + color = labelColor, fontSize = 13.sp, modifier = Modifier.padding(start = 8.dp, top = 8.dp, bottom = 8.dp) ) @@ -121,13 +126,19 @@ fun TextInputField( if (text.isEmpty() && hint != null) { Text( text = hint, - color = HintTextColor, + color = hintColor, fontSize = 16.sp, fontWeight = FontWeight.W400 ) } } if (password) { + // 暗色模式下图标为白色,否则使用默认颜色 + val iconColor = if (AppState.darkMode) { + Color.White + } else { + PasswordIconColor + } Image( painter = painterResource( id = if (showPassword) { @@ -142,7 +153,7 @@ fun TextInputField( .noRippleClickable { showPassword = !showPassword }, - colorFilter = ColorFilter.tint(PasswordIconColor) + colorFilter = ColorFilter.tint(iconColor) ) } } diff --git a/app/src/main/java/com/aiosman/ravenow/ui/login/userauth.kt b/app/src/main/java/com/aiosman/ravenow/ui/login/userauth.kt index 8cb7fea..7cd45f9 100644 --- a/app/src/main/java/com/aiosman/ravenow/ui/login/userauth.kt +++ b/app/src/main/java/com/aiosman/ravenow/ui/login/userauth.kt @@ -72,17 +72,8 @@ fun UserAuthScreen() { var passwordError by remember { mutableStateOf(null) } var captchaInfo by remember { mutableStateOf(null) } fun validateForm(): Boolean { - // 如果密码为空,先检查邮箱格式 - if (password.isEmpty()) { - emailError = when { - email.isEmpty() -> context.getString(R.string.text_error_email_required) - !android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches() -> - context.getString(R.string.text_error_email_format) - else -> null - } - } else { - emailError = if (email.isEmpty()) context.getString(R.string.text_error_email_required) else null - } + emailError = + if (email.isEmpty()) context.getString(R.string.text_error_email_required) else null // 使用通用密码校验器 val passwordValidation = PasswordValidator.validateCurrentPassword(password, context) @@ -250,6 +241,19 @@ fun UserAuthScreen() { ) { StatusBarSpacer() + // 暗色模式下的输入框颜色配置 + val isDarkMode = AppState.darkMode + val inputBackgroundColor = if (isDarkMode) { + Color(0xFF1C1C1C) // 深灰色背景 + } else { + null // 使用默认背景 + } + val hintTextColor = if (isDarkMode) { + Color(0xFFFFFFFF).copy(alpha = 0.7f) // 更明显的白色 hint 文本,透明度 0.7 + } else { + null // 使用默认 hint 颜色 + } + TextInputField( modifier = Modifier .fillMaxWidth(), @@ -258,7 +262,9 @@ fun UserAuthScreen() { email = it }, hint = stringResource(R.string.text_hint_email), - error = emailError + error = emailError, + customBackgroundColor = inputBackgroundColor, + customHintColor = hintTextColor ) Spacer(modifier = Modifier.padding(4.dp)) TextInputField( @@ -270,7 +276,9 @@ fun UserAuthScreen() { }, password = true, hint = stringResource(R.string.text_hint_password), - error = passwordError + error = passwordError, + customBackgroundColor = inputBackgroundColor, + customHintColor = hintTextColor ) Spacer(modifier = Modifier.height(32.dp)) Row( diff --git a/app/src/main/java/com/aiosman/ravenow/ui/post/NewPost.kt b/app/src/main/java/com/aiosman/ravenow/ui/post/NewPost.kt index a651ccf..31a1379 100644 --- a/app/src/main/java/com/aiosman/ravenow/ui/post/NewPost.kt +++ b/app/src/main/java/com/aiosman/ravenow/ui/post/NewPost.kt @@ -375,7 +375,7 @@ fun NewPostTopBar(onSendClick: () -> Unit = {}) { .size(24.dp) .noRippleClickable { // 检查输入 - val errorMessage = model.validateMoment() + val errorMessage = model.validateMoment(context) if (errorMessage != null) { Toast.makeText(context, errorMessage, Toast.LENGTH_SHORT).show() return@noRippleClickable diff --git a/app/src/main/java/com/aiosman/ravenow/ui/post/NewPostViewModel.kt b/app/src/main/java/com/aiosman/ravenow/ui/post/NewPostViewModel.kt index cda495f..d286baf 100644 --- a/app/src/main/java/com/aiosman/ravenow/ui/post/NewPostViewModel.kt +++ b/app/src/main/java/com/aiosman/ravenow/ui/post/NewPostViewModel.kt @@ -22,6 +22,7 @@ import com.aiosman.ravenow.entity.MomentServiceImpl import com.aiosman.ravenow.entity.createMultipartBody import com.aiosman.ravenow.event.MomentAddEvent import com.aiosman.ravenow.exp.rotate +import com.aiosman.ravenow.R import com.aiosman.ravenow.ui.index.tabs.profile.MyProfileViewModel import com.aiosman.ravenow.ui.modification.Modification import com.aiosman.ravenow.utils.FileUtil @@ -151,9 +152,9 @@ object NewPostViewModel : ViewModel() { return tempFile } - fun validateMoment(): String? { + fun validateMoment(context: Context): String? { if (imageList.isEmpty()) { - return "Please select at least one image" + return context.getString(R.string.error_select_at_least_one_image) } return null } From d8ae9186d8d71f2485dcd8eef3957d2db958cbe3 Mon Sep 17 00:00:00 2001 From: zhong <2724770085@qq.com> Date: Wed, 12 Nov 2025 18:47:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E7=A1=AE=E4=BF=9D=E6=9C=88=E3=80=81?= =?UTF-8?q?=E5=A4=A9=E3=80=81=E5=B0=8F=E6=97=B6=E5=92=8C=E7=A7=92=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B8=A4=E4=BD=8D=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/aiosman/ravenow/exp/Date.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/aiosman/ravenow/exp/Date.kt b/app/src/main/java/com/aiosman/ravenow/exp/Date.kt index 8375f99..521ff4f 100644 --- a/app/src/main/java/com/aiosman/ravenow/exp/Date.kt +++ b/app/src/main/java/com/aiosman/ravenow/exp/Date.kt @@ -48,7 +48,7 @@ fun Date.formatPostTime(): String { } /** - * YYYY.DD.MM HH:MM + * yyyy-MM-dd HH:mm */ fun Date.formatPostTime2(): String { val calendar = Calendar.getInstance() @@ -58,7 +58,14 @@ fun Date.formatPostTime2(): String { val day = calendar.get(Calendar.DAY_OF_MONTH) val hour = calendar.get(Calendar.HOUR_OF_DAY) val minute = calendar.get(Calendar.MINUTE) - return "$year.$month.$day $hour:$minute" + + // 确保两位数 + val monthStr = String.format("%02d", month) + val dayStr = String.format("%02d", day) + val hourStr = String.format("%02d", hour) + val minuteStr = String.format("%02d", minute) + + return "$year-$monthStr-$dayStr $hourStr:$minuteStr" } fun Date.formatChatTime(context: Context): String {