@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,17 +72,8 @@ fun UserAuthScreen() {
|
||||
var passwordError by remember { mutableStateOf<String?>(null) }
|
||||
var captchaInfo by remember { mutableStateOf<CaptchaInfo?>(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(
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user