|
@@ -1,8 +1,6 @@
|
|
|
package io.legado.app.ui.widget.components.bookmark
|
|
package io.legado.app.ui.widget.components.bookmark
|
|
|
|
|
|
|
|
-import androidx.compose.foundation.layout.Arrangement
|
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
import androidx.compose.foundation.layout.Column
|
|
|
-import androidx.compose.foundation.layout.Row
|
|
|
|
|
import androidx.compose.foundation.layout.Spacer
|
|
import androidx.compose.foundation.layout.Spacer
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
import androidx.compose.foundation.layout.height
|
|
import androidx.compose.foundation.layout.height
|
|
@@ -13,14 +11,13 @@ import androidx.compose.runtime.getValue
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
import androidx.compose.runtime.remember
|
|
import androidx.compose.runtime.remember
|
|
|
import androidx.compose.runtime.setValue
|
|
import androidx.compose.runtime.setValue
|
|
|
-import androidx.compose.ui.Alignment
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.unit.dp
|
|
import androidx.compose.ui.unit.dp
|
|
|
import io.legado.app.data.entities.Bookmark
|
|
import io.legado.app.data.entities.Bookmark
|
|
|
import io.legado.app.ui.widget.components.AppTextFieldSurface
|
|
import io.legado.app.ui.widget.components.AppTextFieldSurface
|
|
|
import io.legado.app.ui.widget.components.alert.AppAlertDialog
|
|
import io.legado.app.ui.widget.components.alert.AppAlertDialog
|
|
|
-import io.legado.app.ui.widget.components.button.PrimaryButton
|
|
|
|
|
-import io.legado.app.ui.widget.components.button.SecondaryButton
|
|
|
|
|
|
|
+import io.legado.app.ui.widget.components.button.series.SmallTonalButton
|
|
|
|
|
+import io.legado.app.ui.widget.components.icon.AppIcons
|
|
|
import io.legado.app.ui.widget.components.modalBottomSheet.AppModalBottomSheet
|
|
import io.legado.app.ui.widget.components.modalBottomSheet.AppModalBottomSheet
|
|
|
|
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
@@ -32,29 +29,67 @@ fun BookmarkEditSheet(
|
|
|
onSave: (Bookmark) -> Unit,
|
|
onSave: (Bookmark) -> Unit,
|
|
|
onDelete: (Bookmark) -> Unit
|
|
onDelete: (Bookmark) -> Unit
|
|
|
) {
|
|
) {
|
|
|
|
|
+ var showDeleteConfirmDialog by remember { mutableStateOf(false) }
|
|
|
|
|
+ var bookText by remember(bookmark) { mutableStateOf(bookmark.bookText) }
|
|
|
|
|
+ var content by remember(bookmark) { mutableStateOf(bookmark.content) }
|
|
|
|
|
+
|
|
|
AppModalBottomSheet(
|
|
AppModalBottomSheet(
|
|
|
show = show,
|
|
show = show,
|
|
|
onDismissRequest = onDismiss,
|
|
onDismissRequest = onDismiss,
|
|
|
title = bookmark.chapterName,
|
|
title = bookmark.chapterName,
|
|
|
|
|
+ startAction = {
|
|
|
|
|
+ SmallTonalButton(
|
|
|
|
|
+ onClick = { showDeleteConfirmDialog = true },
|
|
|
|
|
+ icon = AppIcons.Delete,
|
|
|
|
|
+ contentDescription = "删除"
|
|
|
|
|
+ )
|
|
|
|
|
+ },
|
|
|
|
|
+ endAction = {
|
|
|
|
|
+ SmallTonalButton(
|
|
|
|
|
+ onClick = {
|
|
|
|
|
+ val newBookmark = bookmark.apply {
|
|
|
|
|
+ this.bookText = bookText
|
|
|
|
|
+ this.content = content
|
|
|
|
|
+ }
|
|
|
|
|
+ onSave(newBookmark)
|
|
|
|
|
+ },
|
|
|
|
|
+ icon = AppIcons.Check,
|
|
|
|
|
+ contentDescription = "保存"
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
) {
|
|
) {
|
|
|
BookmarkEditContent(
|
|
BookmarkEditContent(
|
|
|
bookmark = bookmark,
|
|
bookmark = bookmark,
|
|
|
- onSave = onSave,
|
|
|
|
|
- onDelete = onDelete,
|
|
|
|
|
|
|
+ bookText = bookText,
|
|
|
|
|
+ onBookTextChange = { bookText = it },
|
|
|
|
|
+ content = content,
|
|
|
|
|
+ onContentChange = { content = it },
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ AppAlertDialog(
|
|
|
|
|
+ show = showDeleteConfirmDialog,
|
|
|
|
|
+ onDismissRequest = { showDeleteConfirmDialog = false },
|
|
|
|
|
+ title = "确认删除",
|
|
|
|
|
+ text = "你确定要删除这条书签吗?",
|
|
|
|
|
+ confirmText = "删除",
|
|
|
|
|
+ onConfirm = {
|
|
|
|
|
+ showDeleteConfirmDialog = false
|
|
|
|
|
+ onDelete(bookmark)
|
|
|
|
|
+ },
|
|
|
|
|
+ dismissText = "取消",
|
|
|
|
|
+ onDismiss = { showDeleteConfirmDialog = false }
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Composable
|
|
@Composable
|
|
|
fun BookmarkEditContent(
|
|
fun BookmarkEditContent(
|
|
|
bookmark: Bookmark,
|
|
bookmark: Bookmark,
|
|
|
- onSave: (Bookmark) -> Unit,
|
|
|
|
|
- onDelete: (Bookmark) -> Unit
|
|
|
|
|
|
|
+ bookText: String,
|
|
|
|
|
+ onBookTextChange: (String) -> Unit,
|
|
|
|
|
+ content: String,
|
|
|
|
|
+ onContentChange: (String) -> Unit,
|
|
|
) {
|
|
) {
|
|
|
- var showDeleteConfirmDialog by remember { mutableStateOf(false) }
|
|
|
|
|
- var bookText by remember(bookmark) { mutableStateOf(bookmark.bookText) }
|
|
|
|
|
- var content by remember(bookmark) { mutableStateOf(bookmark.content) }
|
|
|
|
|
-
|
|
|
|
|
Column(
|
|
Column(
|
|
|
modifier = Modifier
|
|
modifier = Modifier
|
|
|
.fillMaxWidth()
|
|
.fillMaxWidth()
|
|
@@ -62,7 +97,7 @@ fun BookmarkEditContent(
|
|
|
) {
|
|
) {
|
|
|
AppTextFieldSurface(
|
|
AppTextFieldSurface(
|
|
|
value = bookText,
|
|
value = bookText,
|
|
|
- onValueChange = { bookText = it },
|
|
|
|
|
|
|
+ onValueChange = onBookTextChange,
|
|
|
label = "原文",
|
|
label = "原文",
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
modifier = Modifier.fillMaxWidth(),
|
|
|
maxLines = 10
|
|
maxLines = 10
|
|
@@ -72,51 +107,12 @@ fun BookmarkEditContent(
|
|
|
|
|
|
|
|
AppTextFieldSurface(
|
|
AppTextFieldSurface(
|
|
|
value = content,
|
|
value = content,
|
|
|
- onValueChange = { content = it },
|
|
|
|
|
|
|
+ onValueChange = onContentChange,
|
|
|
label = "摘要/笔记",
|
|
label = "摘要/笔记",
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
modifier = Modifier.fillMaxWidth(),
|
|
|
maxLines = 5
|
|
maxLines = 5
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- Spacer(modifier = Modifier.height(24.dp))
|
|
|
|
|
-
|
|
|
|
|
- Row(
|
|
|
|
|
- modifier = Modifier.fillMaxWidth(),
|
|
|
|
|
- horizontalArrangement = Arrangement.spacedBy(12.dp),
|
|
|
|
|
- verticalAlignment = Alignment.CenterVertically
|
|
|
|
|
- ) {
|
|
|
|
|
- SecondaryButton(
|
|
|
|
|
- onClick = { showDeleteConfirmDialog = true },
|
|
|
|
|
- modifier = Modifier.weight(1f),
|
|
|
|
|
- text = "删除"
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
- PrimaryButton(
|
|
|
|
|
- onClick = {
|
|
|
|
|
- val newBookmark = bookmark.apply {
|
|
|
|
|
- this.bookText = bookText
|
|
|
|
|
- this.content = content
|
|
|
|
|
- }
|
|
|
|
|
- onSave(newBookmark)
|
|
|
|
|
- },
|
|
|
|
|
- modifier = Modifier.weight(1f),
|
|
|
|
|
- text = "保存"
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
Spacer(modifier = Modifier.height(16.dp))
|
|
Spacer(modifier = Modifier.height(16.dp))
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- AppAlertDialog(
|
|
|
|
|
- show = showDeleteConfirmDialog,
|
|
|
|
|
- onDismissRequest = { showDeleteConfirmDialog = false },
|
|
|
|
|
- title = "确认删除",
|
|
|
|
|
- text = "你确定要删除这条书签吗?",
|
|
|
|
|
- confirmText = "删除",
|
|
|
|
|
- onConfirm = {
|
|
|
|
|
- showDeleteConfirmDialog = false
|
|
|
|
|
- onDelete(bookmark)
|
|
|
|
|
- },
|
|
|
|
|
- dismissText = "取消",
|
|
|
|
|
- onDismiss = { showDeleteConfirmDialog = false }
|
|
|
|
|
- )
|
|
|
|
|
}
|
|
}
|