首页搜索调整
This commit is contained in:
@@ -4,11 +4,13 @@ import android.widget.Toast
|
|||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.text.BasicTextField
|
import androidx.compose.foundation.text.BasicTextField
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
@@ -23,6 +25,7 @@ import androidx.compose.runtime.setValue
|
|||||||
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.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
@@ -35,6 +38,10 @@ import com.aiosman.ravenow.AppStore
|
|||||||
import com.aiosman.ravenow.Messaging
|
import com.aiosman.ravenow.Messaging
|
||||||
import com.aiosman.ravenow.R
|
import com.aiosman.ravenow.R
|
||||||
import com.aiosman.ravenow.data.AccountServiceImpl
|
import com.aiosman.ravenow.data.AccountServiceImpl
|
||||||
|
import com.aiosman.ravenow.data.ServiceException
|
||||||
|
import com.aiosman.ravenow.data.api.ErrorCode
|
||||||
|
import com.aiosman.ravenow.data.api.showToast
|
||||||
|
import com.aiosman.ravenow.data.api.toErrorMessage
|
||||||
import com.aiosman.ravenow.ui.NavigationRoute
|
import com.aiosman.ravenow.ui.NavigationRoute
|
||||||
import com.aiosman.ravenow.ui.comment.NoticeScreenHeader
|
import com.aiosman.ravenow.ui.comment.NoticeScreenHeader
|
||||||
import com.aiosman.ravenow.ui.composables.ActionButton
|
import com.aiosman.ravenow.ui.composables.ActionButton
|
||||||
@@ -46,10 +53,16 @@ fun RemoveAccountScreen() {
|
|||||||
val appColors = LocalAppTheme.current
|
val appColors = LocalAppTheme.current
|
||||||
val navController = LocalNavController.current
|
val navController = LocalNavController.current
|
||||||
var inputPassword by remember { mutableStateOf("") }
|
var inputPassword by remember { mutableStateOf("") }
|
||||||
|
var passwordError by remember { mutableStateOf<String?>(null) }
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
fun removeAccount(password: String) {
|
fun removeAccount(password: String) {
|
||||||
|
if (password.isEmpty()) {
|
||||||
|
passwordError = "Please enter your correct password"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
scope.launch {
|
scope.launch {
|
||||||
try {
|
try {
|
||||||
val accountService = AccountServiceImpl()
|
val accountService = AccountServiceImpl()
|
||||||
@@ -60,17 +73,21 @@ fun RemoveAccountScreen() {
|
|||||||
rememberMe = false
|
rememberMe = false
|
||||||
saveData()
|
saveData()
|
||||||
}
|
}
|
||||||
// 删除推送渠道
|
//返回到登录页面
|
||||||
AppState.ReloadAppState(context)
|
|
||||||
navController.navigate(NavigationRoute.Login.route) {
|
navController.navigate(NavigationRoute.Login.route) {
|
||||||
popUpTo(NavigationRoute.Login.route) {
|
popUpTo(NavigationRoute.Login.route) {
|
||||||
inclusive = true
|
inclusive = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//重置AppState
|
||||||
|
AppState.ReloadAppState(context)
|
||||||
|
Toast.makeText(context, "Account has been deleted", Toast.LENGTH_SHORT).show()
|
||||||
|
} catch (e: ServiceException) {
|
||||||
|
passwordError = "Incorrect password"
|
||||||
|
// e.errorType.showToast(context)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
// show toast
|
Toast.makeText(context, "An error occurred. Please try again.", Toast.LENGTH_SHORT).show()
|
||||||
Toast.makeText(context, e.message, Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,17 +146,56 @@ fun RemoveAccountScreen() {
|
|||||||
|
|
||||||
BasicTextField(
|
BasicTextField(
|
||||||
value = inputPassword,
|
value = inputPassword,
|
||||||
onValueChange = { inputPassword = it },
|
onValueChange = {
|
||||||
|
inputPassword = it
|
||||||
|
if (passwordError != null) {
|
||||||
|
passwordError = null
|
||||||
|
}
|
||||||
|
},
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
textStyle = TextStyle(color = appColors.text),
|
textStyle = TextStyle(color = appColors.text),
|
||||||
cursorBrush = SolidColor(appColors.text)
|
cursorBrush = SolidColor(appColors.text)
|
||||||
)
|
)
|
||||||
|
if (inputPassword.isEmpty()) {
|
||||||
|
Text(
|
||||||
|
"Please enter your correct password",
|
||||||
|
modifier = Modifier.padding(start = 5.dp),
|
||||||
|
color = appColors.inputHint,
|
||||||
|
fontWeight = FontWeight.W600
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// 显示密码错误信息
|
||||||
|
passwordError?.let {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(top = 4.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
androidx.compose.foundation.Image(
|
||||||
|
painter = painterResource(id = R.mipmap.rider_pro_input_error),
|
||||||
|
contentDescription = "Error",
|
||||||
|
modifier = Modifier.size(8.dp)
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.size(4.dp))
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = it,
|
||||||
|
color = androidx.compose.ui.graphics.Color.Red,
|
||||||
|
fontSize = 14.sp,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(top = 4.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
ActionButton(
|
ActionButton(
|
||||||
text = stringResource(R.string.remove_account),
|
text = stringResource(R.string.remove_account),
|
||||||
fullWidth = true,
|
fullWidth = true,
|
||||||
enabled = inputPassword.isNotEmpty(),
|
enabled = true,
|
||||||
click = {
|
click = {
|
||||||
removeAccount(inputPassword)
|
removeAccount(inputPassword)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import androidx.compose.ui.graphics.Color
|
|||||||
import androidx.compose.ui.graphics.SolidColor
|
import androidx.compose.ui.graphics.SolidColor
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||||
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
@@ -154,20 +155,24 @@ fun SearchScreen() {
|
|||||||
) {
|
) {
|
||||||
Box {
|
Box {
|
||||||
TabItem(
|
TabItem(
|
||||||
text = stringResource(R.string.users),
|
text = stringResource(R.string.moment),
|
||||||
isSelected = pagerState.currentPage == 0,
|
isSelected = pagerState.currentPage == 0,
|
||||||
onClick = {
|
onClick = {
|
||||||
// TODO: 实现点击逻辑
|
coroutineScope.launch {
|
||||||
|
pagerState.animateScrollToPage(0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
TabSpacer()
|
TabSpacer()
|
||||||
Box {
|
Box {
|
||||||
TabItem(
|
TabItem(
|
||||||
text = stringResource(R.string.index_dynamic),
|
text = stringResource(R.string.users),
|
||||||
isSelected = pagerState.currentPage == 1,
|
isSelected = pagerState.currentPage == 1,
|
||||||
onClick = {
|
onClick = {
|
||||||
// TODO: 实现点击逻辑
|
coroutineScope.launch {
|
||||||
|
pagerState.animateScrollToPage(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -304,6 +309,34 @@ fun MomentResultTab() {
|
|||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.background(AppColors.background)
|
.background(AppColors.background)
|
||||||
) {
|
) {
|
||||||
|
if (moments.itemCount == 0 && model.showResult) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(16.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
androidx.compose.foundation.Image(
|
||||||
|
painter = painterResource(id = R.mipmap.rider_pro_followers_empty),
|
||||||
|
contentDescription = "No Comment",
|
||||||
|
modifier = Modifier.size(140.dp)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "咦,什么都没找到...",
|
||||||
|
color = LocalAppTheme.current.text,
|
||||||
|
fontSize = 16.sp,
|
||||||
|
fontWeight = FontWeight.W600
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
Text(
|
||||||
|
text = "换个关键词试试吧,也许会有新发现!",
|
||||||
|
color = LocalAppTheme.current.secondaryText,
|
||||||
|
fontSize = 14.sp,
|
||||||
|
fontWeight = FontWeight.W400
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
) {
|
) {
|
||||||
@@ -326,6 +359,7 @@ fun MomentResultTab() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -336,6 +370,34 @@ fun UserResultTab() {
|
|||||||
Box(
|
Box(
|
||||||
modifier = Modifier.fillMaxSize()
|
modifier = Modifier.fillMaxSize()
|
||||||
) {
|
) {
|
||||||
|
if (users.itemCount == 0 && model.showResult) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(16.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
androidx.compose.foundation.Image(
|
||||||
|
painter = painterResource(id = R.mipmap.rider_pro_followers_empty),
|
||||||
|
contentDescription = "No Comment",
|
||||||
|
modifier = Modifier.size(140.dp)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "咦,什么都没找到...",
|
||||||
|
color = LocalAppTheme.current.text,
|
||||||
|
fontSize = 16.sp,
|
||||||
|
fontWeight = FontWeight.W600
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
Text(
|
||||||
|
text = "换个关键词试试吧,也许会有新发现!",
|
||||||
|
color = LocalAppTheme.current.secondaryText,
|
||||||
|
fontSize = 14.sp,
|
||||||
|
fontWeight = FontWeight.W400
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
) {
|
) {
|
||||||
@@ -353,6 +415,7 @@ fun UserResultTab() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
Reference in New Issue
Block a user