feat: two column title text

This commit is contained in:
lisonge 2024-05-29 20:00:08 +08:00
parent a75f3b93a3
commit 747a20ac3c
5 changed files with 65 additions and 37 deletions

View File

@ -129,17 +129,19 @@ fun AppItemPage(
)
}
}, title = {
val text = if (subsRaw == null) {
"订阅文件缺失"
} else {
"${appInfoCache[appId]?.name ?: appRaw.name ?: appId}/${subsRaw.name}"
Column {
Text(
text = subsRaw?.name ?: subsItemId.toString(),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Text(
text = appInfoCache[appId]?.name ?: appRaw.name ?: appId,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.bodyMedium,
)
}
Text(
text = text,
maxLines = 1,
softWrap = false,
overflow = TextOverflow.Ellipsis,
)
}, actions = {})
}, floatingActionButton = {
if (editable) {

View File

@ -40,6 +40,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.viewModelScope
@ -92,7 +93,16 @@ fun CategoryPage(subsItemId: Long) {
contentDescription = null,
)
}
}, title = { Text(text = "规则类别/${subsRaw?.name ?: subsItemId}") }, actions = {})
}, title = {
Column {
Text(
text = subsRaw?.name ?: subsItemId.toString(),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Text(text = "规则类别", style = MaterialTheme.typography.bodyMedium)
}
}, actions = {})
}, floatingActionButton = {
if (editable) {
FloatingActionButton(onClick = { showAddDlg = true }) {
@ -260,14 +270,13 @@ fun CategoryPage(subsItemId: Long) {
vm.viewModelScope.launchTry(Dispatchers.IO) {
subsItem?.apply {
updateSubscription(
subsRawVal.copy(categories = categories.toMutableList()
.apply {
val i =
categories.indexOfFirst { c -> c.key == editNameCategory.key }
if (i >= 0) {
set(i, editNameCategory.copy(name = source))
}
})
subsRawVal.copy(categories = categories.toMutableList().apply {
val i =
categories.indexOfFirst { c -> c.key == editNameCategory.key }
if (i >= 0) {
set(i, editNameCategory.copy(name = source))
}
})
)
DbSet.subsItemDao.update(copy(mtime = System.currentTimeMillis()))
}
@ -305,11 +314,10 @@ fun CategoryPage(subsItemId: Long) {
vm.viewModelScope.launchTry(Dispatchers.IO) {
subsItem?.apply {
updateSubscription(
subsRawVal.copy(categories = categories.toMutableList()
.apply {
add(RawSubscription.RawCategory(key = (categories.maxOfOrNull { c -> c.key }
?: -1) + 1, name = source, enable = null))
})
subsRawVal.copy(categories = categories.toMutableList().apply {
add(RawSubscription.RawCategory(key = (categories.maxOfOrNull { c -> c.key }
?: -1) + 1, name = source, enable = null))
})
)
DbSet.subsItemDao.update(copy(mtime = System.currentTimeMillis()))
toast("添加成功")

View File

@ -129,12 +129,19 @@ fun GlobalRuleExcludePage(subsItemId: Long, groupKey: Int) {
modifier = Modifier.focusRequester(focusRequester)
)
} else {
Text(
text = "${rawSubs?.name ?: subsItemId}/${group?.name ?: groupKey}",
maxLines = 1,
softWrap = false,
overflow = TextOverflow.Ellipsis,
)
Column {
Text(
text = rawSubs?.name ?: subsItemId.toString(),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Text(
text = (group?.name ?: groupKey.toString()),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.bodyMedium
)
}
}
}, actions = {
if (showSearchBar) {

View File

@ -116,7 +116,14 @@ fun GlobalRulePage(subsItemId: Long, focusGroupKey: Int? = null) {
)
}
}, title = {
Text(text = "全局规则/${rawSubs?.name ?: subsItemId}")
Column {
Text(
text = rawSubs?.name ?: subsItemId.toString(),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Text(text = "全局规则", style = MaterialTheme.typography.bodyMedium)
}
})
},
floatingActionButton = {

View File

@ -1,6 +1,7 @@
package li.songe.gkd.ui
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
@ -24,6 +25,7 @@ import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Scaffold
@ -149,12 +151,14 @@ fun SubsPage(
modifier = Modifier.focusRequester(focusRequester)
)
} else {
Text(
text = "应用规则/${subsRaw?.name ?: subsItemId}",
maxLines = 1,
softWrap = false,
overflow = TextOverflow.Ellipsis,
)
Column {
Text(
text = subsRaw?.name ?: subsItemId.toString(),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Text(text = "应用规则", style = MaterialTheme.typography.bodyMedium)
}
}
}, actions = {
if (showSearchBar) {