Skip to content

Commit

Permalink
Merge pull request #88 from dmzz-yyhyy/settings_optimizations
Browse files Browse the repository at this point in the history
优化开关设置项
  • Loading branch information
dmzz-yyhyy authored Aug 31, 2024
2 parents 454fccf + 00e95d4 commit 4b65ee3
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android {
minSdk = 24
targetSdk = 34
// 版本号为x.y.z则versionCode为x*1000000+y*10000+z*100+debug版本号(开发需要时迭代, 两位数)
versionCode = 4_04_010
versionCode = 4_04_012
versionName = "0.4.4"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,22 @@ fun SettingsSwitchEntry(
onCheckedChange: (Boolean) -> Unit,
) {
FilledCard(
modifier = Modifier.fillMaxWidth(),
modifier = Modifier
.fillMaxWidth(),
shape = RoundedCornerShape(6.dp)
) {
Row(
modifier = Modifier
.fillMaxWidth()
.clickable { onCheckedChange(!checked) }
.padding(18.dp, 10.dp, 20.dp, 12.dp),
verticalAlignment = Alignment.CenterVertically) {
Column (
verticalAlignment = Alignment.CenterVertically
) {
Column(
Modifier
.weight(2f)
.padding(end = 4.dp)) {
.padding(end = 4.dp)
) {
Text(
text = title,
style = MaterialTheme.typography.titleLarge,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ package indi.dmzz_yyhyy.lightnovelreader.ui.home.bookshelf.edit
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsFocusedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
Expand Down Expand Up @@ -79,7 +82,9 @@ fun EditBookshelfScreen(
}
Column {
OutlinedTextField(
modifier = Modifier.fillMaxWidth().padding(20.dp),
modifier = Modifier
.fillMaxWidth()
.padding(20.dp),
value = bookshelf.name,
onValueChange = onNameChange,
label = { Text("名称") },
Expand Down Expand Up @@ -110,23 +115,32 @@ fun EditBookshelfScreen(
color = MaterialTheme.colorScheme.onSurfaceVariant
)
SwitchSettingItem(
iconRes = R.drawable.cloud_download_24px,
title = "自动缓存",
description = "自动缓存新加入的书本完整内容",
value = bookshelf.autoCache,
onValueChange = onAutoCacheChange
)
SwitchSettingItem(
iconRes = R.drawable.outline_schedule_24px,
title = "更新通知提醒",
description = "如果书本有更新,通过系统通知提示我(限后台时)",
description = "在后台时,检查并通知书本更新",
value = bookshelf.systemUpdateReminder,
onValueChange = onSystemUpdateReminderChange
)
ListItem(
modifier = Modifier.clickable {
dialogVisible = true
},
headlineContent = { Text(text = "删除此书架", style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.W500, fontSize = 16.sp) },
supportingContent = { Text(text = "将此书架永久移除", style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.W500, fontSize = 12.sp, lineHeight = 14.sp, color = MaterialTheme.colorScheme.onSurfaceVariant) },
leadingContent = {
Icon(
modifier = Modifier.padding(horizontal = 10.dp),
painter = painterResource(R.drawable.delete_forever_24px),
contentDescription = "Localized description",
)
},
headlineContent = { Text(text = "删除此书架", fontSize = 16.sp, modifier = Modifier.padding(bottom = 2.dp)) },
supportingContent = { Text(text = "将此书架永久移除", fontSize = 14.sp, lineHeight = 15.sp) },
)
}
}
Expand Down Expand Up @@ -175,20 +189,29 @@ private fun TopBar(

@Composable
fun SwitchSettingItem(
iconRes: Int,
title: String,
description: String,
value: Boolean,
onValueChange: (Boolean) -> Unit,
) {
ListItem(
headlineContent = { Text(text = title, style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.W500, fontSize = 16.sp) },
supportingContent = { Text(text = description, style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.W500, fontSize = 12.sp, lineHeight = 14.sp, color = MaterialTheme.colorScheme.onSurfaceVariant) },
modifier = Modifier.clickable {onValueChange(!value)},
headlineContent = { Text(text = title, fontSize = 16.sp, modifier = Modifier.padding(bottom = 2.dp)) },
supportingContent = { Text(text = description, fontSize = 14.sp, lineHeight = 15.sp) },
trailingContent = {
Switch(
checked = value,
onCheckedChange = onValueChange
)
}
},
leadingContent = {
Icon(
modifier = Modifier.padding(horizontal = 10.dp),
painter = painterResource(iconRes),
contentDescription = "Localized description",
)
},
)
}

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/delete_forever_24px.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M376,660L480,556L584,660L640,604L536,500L640,396L584,340L480,444L376,340L320,396L424,500L320,604L376,660ZM280,840Q247,840 223.5,816.5Q200,793 200,760L200,240L160,240L160,160L360,160L360,120L600,120L600,160L800,160L800,240L760,240L760,760Q760,793 736.5,816.5Q713,840 680,840L280,840ZM680,240L280,240L280,760Q280,760 280,760Q280,760 280,760L680,760Q680,760 680,760Q680,760 680,760L680,240ZM280,240L280,240L280,760Q280,760 280,760Q280,760 280,760L280,760Q280,760 280,760Q280,760 280,760L280,240Z"/>
</vector>

0 comments on commit 4b65ee3

Please sign in to comment.