1、修改首次添加图标库时数据没有写入缓存问题
2、优化图标库界面
This commit is contained in:
1 parent
4a7adfadaa
commit
8eea806ca6
2 files changed
+45
-39
No files matched your search
@@ -57,7 +57,14 @@ object IconLibraryRepository {
|
||||
|
||||
suspend fun addLibrary(library: IconLibrary) {
|
||||
save(library)
|
||||
setRuntimeIcons(library.id, library.icons)
|
||||
if (library.icons.isNotEmpty()) {
|
||||
setRuntimeIcons(library.id, library.icons)
|
||||
cachedIcons[library.id] = library.icons
|
||||
saveIconsToCache(library.id, library.icons)
|
||||
withContext(Dispatchers.IO) {
|
||||
database?.iconLibraryDao()?.updateIconCount(library.id, library.icons.size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun removeLibrary(id: String) {
|
||||
|
||||
@@ -12,6 +12,8 @@ import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.gestures.detectHorizontalDragGestures
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
@@ -398,13 +400,40 @@ fun IconLibraryManagerScreen(
|
||||
|
||||
val editingLibrary = editingLibraryId?.let { id -> libraries.find { it.id == id } }
|
||||
|
||||
Column(modifier.fillMaxSize()) {
|
||||
Column(modifier.fillMaxSize()
|
||||
.pointerInput(Unit) {
|
||||
var totalDrag = 0f
|
||||
detectHorizontalDragGestures(
|
||||
onDragStart = { totalDrag = 0f },
|
||||
onDragEnd = {
|
||||
if (totalDrag > 300f) onBack()
|
||||
},
|
||||
) { _, dragAmount ->
|
||||
totalDrag += dragAmount
|
||||
}
|
||||
}
|
||||
) {
|
||||
LiquidGlassTopBar {
|
||||
Row(
|
||||
Modifier.fillMaxWidth().padding(horizontal = 18.dp, vertical = 12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Box(Modifier.width(86.dp)) {
|
||||
Box(
|
||||
Modifier.size(34.dp)
|
||||
.clip(CircleShape)
|
||||
.background(Color.White.copy(alpha = 0.42f))
|
||||
.border(1.dp, Color.White.copy(alpha = 0.55f), CircleShape)
|
||||
.clickable(indication = null, interactionSource = remember { MutableInteractionSource() }) { onBack() },
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Icon(Icons.Outlined.Close, contentDescription = "\u8FD4\u56DE", tint = GlassTokens.text, modifier = Modifier.size(19.dp))
|
||||
}
|
||||
}
|
||||
Box(Modifier.weight(1f), contentAlignment = Alignment.Center) {
|
||||
Text("\u56FE\u6807\u5E93\u7BA1\u7406", color = GlassTokens.text, fontSize = 19.sp, fontWeight = FontWeight.Bold)
|
||||
}
|
||||
Box(Modifier.width(86.dp), contentAlignment = Alignment.CenterEnd) {
|
||||
Row(
|
||||
Modifier.clip(RoundedCornerShape(20.dp))
|
||||
.background(GlassTokens.accent.copy(alpha = 0.15f))
|
||||
@@ -418,21 +447,6 @@ fun IconLibraryManagerScreen(
|
||||
Text("\u6DFB\u52A0", color = GlassTokens.accent, fontSize = 13.sp, fontWeight = FontWeight.SemiBold)
|
||||
}
|
||||
}
|
||||
Box(Modifier.weight(1f), contentAlignment = Alignment.Center) {
|
||||
Text("\u56FE\u6807\u5E93\u7BA1\u7406", color = GlassTokens.text, fontSize = 19.sp, fontWeight = FontWeight.Bold)
|
||||
}
|
||||
Box(Modifier.width(86.dp), contentAlignment = Alignment.CenterEnd) {
|
||||
Box(
|
||||
Modifier.size(34.dp)
|
||||
.clip(CircleShape)
|
||||
.background(Color.White.copy(alpha = 0.42f))
|
||||
.border(1.dp, Color.White.copy(alpha = 0.55f), CircleShape)
|
||||
.clickable(indication = null, interactionSource = remember { MutableInteractionSource() }) { onBack() },
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Icon(Icons.Outlined.Close, contentDescription = "\u8FD4\u56DE", tint = GlassTokens.text, modifier = Modifier.size(19.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,7 +470,7 @@ fun IconLibraryManagerScreen(
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Icon(Icons.Outlined.Image, contentDescription = null, tint = GlassTokens.subtext, modifier = Modifier.size(32.dp))
|
||||
Text("\u8FD8\u6CA1\u6709\u56FE\u6807\u5E93", color = GlassTokens.subtext, fontSize = 15.sp)
|
||||
Text("\u70B9\u51FB\u5DE6\u4E0A\u89D2\u6DFB\u52A0", color = GlassTokens.subtext.copy(alpha = 0.75f), fontSize = 12.sp)
|
||||
Text("\u70B9\u51FB\u53F3\u4E0A\u89D2\u6DFB\u52A0", color = GlassTokens.subtext.copy(alpha = 0.75f), fontSize = 12.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -541,7 +555,7 @@ private fun IconLibraryManagerCard(library: IconLibrary, onClick: () -> Unit) {
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(11.dp))
|
||||
Row(horizontalArrangement = Arrangement.spacedBy((-5).dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically) {
|
||||
library.icons.take(4).forEach { icon ->
|
||||
Box(
|
||||
Modifier.size(34.dp).clip(RoundedCornerShape(9.dp))
|
||||
@@ -569,12 +583,6 @@ private fun IconLibraryManagerCard(library: IconLibrary, onClick: () -> Unit) {
|
||||
.background(Color.White.copy(alpha = 0.30f)),
|
||||
contentAlignment = Alignment.Center,
|
||||
) { Text("\u6682\u65E0\u56FE\u6807", color = GlassTokens.subtext, fontSize = 11.sp) }
|
||||
} else if (library.iconCount > 4) {
|
||||
Box(
|
||||
Modifier.size(34.dp).clip(RoundedCornerShape(9.dp))
|
||||
.background(GlassTokens.accent.copy(alpha = 0.12f)),
|
||||
contentAlignment = Alignment.Center,
|
||||
) { Text("+${library.iconCount - 4}", color = GlassTokens.accent, fontSize = 10.sp, fontWeight = FontWeight.Bold) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -691,16 +699,7 @@ private fun IconLibraryCard(
|
||||
)
|
||||
}
|
||||
}
|
||||
if (library.iconCount > 3) {
|
||||
Box(
|
||||
Modifier.size(30.dp).clip(RoundedCornerShape(8.dp))
|
||||
.background(Brush.verticalGradient(listOf(Color(0xFF9B9B9B).copy(alpha = 0.2f), Color(0xFF9B9B9B).copy(alpha = 0.1f))))
|
||||
.border(0.5.dp, Color.White.copy(alpha = 0.5f), RoundedCornerShape(8.dp)),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Text("+${library.iconCount - 3}", fontSize = 10.sp, color = GlassTokens.subtext, fontWeight = FontWeight.Medium)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text(library.name, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = GlassTokens.text, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
@@ -907,10 +906,10 @@ private fun ManageIconLibraryDialog(
|
||||
if (library.icons.isNotEmpty()) {
|
||||
Text("\u56FE\u6807\u9884\u89C8", fontSize = 13.sp, color = GlassTokens.subtext, fontWeight = FontWeight.Medium)
|
||||
LazyVerticalGrid(
|
||||
columns = GridCells.Fixed(6),
|
||||
modifier = Modifier.heightIn(min = 80.dp, max = 180.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
columns = GridCells.Fixed(5),
|
||||
modifier = Modifier.heightIn(min = 80.dp, max = 320.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(6.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||
) {
|
||||
items(library.icons) { icon ->
|
||||
Box(
|
||||
|
||||
Reference in new issue
Block a user