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