style: string
This commit is contained in:
@@ -85,8 +85,7 @@ fun App(viewModel: PostViewModel = viewModel()) {
|
||||
|
||||
NavHost(navController, startDestination = NAV_ROUTE_POSTLIST_SCREEN) {
|
||||
composable(NAV_ROUTE_POSTLIST_SCREEN) {
|
||||
PostListScreen(onNavigateToDetail = {
|
||||
}, navController = navController, viewModel = viewModel)
|
||||
PostListScreen(navController = navController, viewModel = viewModel)
|
||||
}
|
||||
|
||||
composable(NAV_ROUTE_DETAIL_SCREEN) {
|
||||
|
||||
@@ -77,17 +77,17 @@ fun DetailScreen(navController: NavController, viewModel: PostViewModel) {
|
||||
title = {},
|
||||
navigationIcon = {
|
||||
IconButton(onClick = { navController.popBackStack() }) {
|
||||
Icon(imageVector = Icons.Filled.ArrowBack, contentDescription = "back")
|
||||
Icon(imageVector = Icons.Filled.ArrowBack, contentDescription = R.string.description_back.toString())
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
IconButton(onClick = {
|
||||
viewModel.actionDownload()
|
||||
Toast.makeText(context, "Start download", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.toast_download_start, Toast.LENGTH_SHORT).show()
|
||||
}) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_twotone_arrow_downward_24),
|
||||
contentDescription = "Download"
|
||||
contentDescription = R.string.description_download.toString()
|
||||
)
|
||||
}
|
||||
IconButton(onClick = {
|
||||
@@ -97,7 +97,7 @@ fun DetailScreen(navController: NavController, viewModel: PostViewModel) {
|
||||
}) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Share,
|
||||
contentDescription = "Share",
|
||||
contentDescription = R.string.description_share.toString(),
|
||||
tint = Color.White
|
||||
)
|
||||
}
|
||||
@@ -108,7 +108,7 @@ fun DetailScreen(navController: NavController, viewModel: PostViewModel) {
|
||||
}) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_twotone_wallpaper_24),
|
||||
contentDescription = "Use to wallpaper",
|
||||
contentDescription = R.string.description_use_to_wallpaper.toString(),
|
||||
tint = Color.White
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lsp.view.ui.compose.screen
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.slideInVertically
|
||||
@@ -64,7 +63,6 @@ import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlin.random.Random
|
||||
|
||||
@OptIn(
|
||||
ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class,
|
||||
@@ -72,7 +70,7 @@ import kotlin.random.Random
|
||||
)
|
||||
@Composable
|
||||
fun PostListScreen(
|
||||
navController: NavController, onNavigateToDetail: (Post) -> Unit, viewModel: PostViewModel
|
||||
navController: NavController, viewModel: PostViewModel
|
||||
) {
|
||||
val postList by viewModel.postData.collectAsState()
|
||||
val listState = rememberLazyStaggeredGridState()
|
||||
@@ -147,10 +145,12 @@ fun PostListScreen(
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||
content = {
|
||||
//空置一行显示search bar
|
||||
item(key = 0,span = StaggeredGridItemSpan.FullLine){
|
||||
Box(modifier = Modifier
|
||||
.height(searchBarHeightSize + searchBarPadding)
|
||||
.fillMaxWidth())
|
||||
item(key = 0, span = StaggeredGridItemSpan.FullLine) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.height(searchBarHeightSize + searchBarPadding)
|
||||
.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
|
||||
items(items = postList, key = {
|
||||
@@ -172,10 +172,12 @@ fun PostListScreen(
|
||||
|
||||
)
|
||||
|
||||
PullRefreshIndicator(refreshing, pullRefreshState,
|
||||
PullRefreshIndicator(
|
||||
refreshing, pullRefreshState,
|
||||
Modifier
|
||||
.align(Alignment.TopCenter)
|
||||
.padding(searchBarHeightSize + searchBarPadding))
|
||||
.padding(searchBarHeightSize + searchBarPadding)
|
||||
)
|
||||
|
||||
AnimatedVisibility(
|
||||
visible = scrollDirectionState != -1,
|
||||
@@ -213,16 +215,26 @@ fun PostListScreen(
|
||||
)
|
||||
}
|
||||
|
||||
if (showBottomSheet){
|
||||
if (showBottomSheet) {
|
||||
var safeModel by remember {
|
||||
mutableStateOf(Config.getSafeMode())
|
||||
}
|
||||
ModalBottomSheet(onDismissRequest ={showBottomSheet = false}, modifier = Modifier.height(400.dp)){
|
||||
Row(modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically) {
|
||||
Text(text = "Safe mode", modifier = Modifier.wrapContentSize(), style = MaterialTheme.typography.bodyLarge)
|
||||
ModalBottomSheet(
|
||||
onDismissRequest = { showBottomSheet = false },
|
||||
modifier = Modifier.height(400.dp)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(
|
||||
text = "Safe mode",
|
||||
modifier = Modifier.wrapContentSize(),
|
||||
style = MaterialTheme.typography.bodyLarge
|
||||
)
|
||||
Switch(checked = safeModel, onCheckedChange = {
|
||||
safeModel = it
|
||||
Config.setSafeMode(it)
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
<string name="item_search">搜索</string>
|
||||
<string name="description_download">下载</string>
|
||||
<string name="description_share">分享</string>
|
||||
<string name="description_use_to_wallpaper">用作壁纸</string>
|
||||
<string name="description_back">返回</string>
|
||||
<string name="activity_login_login">登录</string>
|
||||
<string name="activity_login_account">账户</string>
|
||||
<string name="activity_login_password">密码</string>
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
<string name="item_search">Search</string>
|
||||
<string name="description_download">Download</string>
|
||||
<string name="description_share">Share</string>
|
||||
<string name="description_use_to_wallpaper">Use to wallpaper</string>
|
||||
<string name="description_back">Back</string>
|
||||
<string name="activity_login_login">Login</string>
|
||||
<string name="activity_login_account">Account</string>
|
||||
<string name="activity_login_password">Password</string>
|
||||
|
||||
Reference in New Issue
Block a user