Merge branch 'main' of https://github.com/vitorpamplona/amethyst
* 'main' of https://github.com/vitorpamplona/amethyst: Remove delay, and implement custom moving function that updates the list in one event, rather than two with the previous approach. Increase delay time in moveBookmark. Need to find a better alternative to delay. String resources. Re-introduce display stats for bookmark list, focusing on total bookmarks size per category. Support moving articles/posts from private to public and vice versa.
This commit is contained in:
+17
@@ -265,6 +265,23 @@ class LabeledBookmarkListsState(
|
|||||||
account.sendMyPublicAndPrivateOutbox(updatedList)
|
account.sendMyPublicAndPrivateOutbox(updatedList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun moveBookmarkInList(
|
||||||
|
bookmark: BookmarkIdTag,
|
||||||
|
bookmarkListIdentifier: String,
|
||||||
|
isBookmarkCurrentlyPrivate: Boolean,
|
||||||
|
account: Account,
|
||||||
|
) {
|
||||||
|
val bookmarkList = getLabeledBookmarkListEvent(bookmarkListIdentifier)
|
||||||
|
val updatedList =
|
||||||
|
LabeledBookmarkListEvent.moveBookmark(
|
||||||
|
earlierVersion = bookmarkList,
|
||||||
|
bookmarkIdTag = bookmark,
|
||||||
|
isCurrentlyPrivate = isBookmarkCurrentlyPrivate,
|
||||||
|
signer = account.signer,
|
||||||
|
)
|
||||||
|
account.sendMyPublicAndPrivateOutbox(updatedList)
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun removeBookmarkFromList(
|
suspend fun removeBookmarkFromList(
|
||||||
bookmark: BookmarkIdTag,
|
bookmark: BookmarkIdTag,
|
||||||
bookmarkListIdentifier: String,
|
bookmarkListIdentifier: String,
|
||||||
|
|||||||
+15
@@ -43,6 +43,7 @@ fun RenderArticleList(
|
|||||||
bookmarkGroupViewModel: BookmarkGroupViewModel,
|
bookmarkGroupViewModel: BookmarkGroupViewModel,
|
||||||
pagerState: PagerState,
|
pagerState: PagerState,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
moveArticleBookmark: (articleAddress: Address, fromPrivate: Boolean) -> Unit,
|
||||||
deleteArticleBookmark: (articleAddress: Address, isPrivate: Boolean) -> Unit,
|
deleteArticleBookmark: (articleAddress: Address, isPrivate: Boolean) -> Unit,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
@@ -56,6 +57,10 @@ fun RenderArticleList(
|
|||||||
ArticleList(
|
ArticleList(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
articles = publicArticles,
|
articles = publicArticles,
|
||||||
|
isArticleBookmarkPrivate = false,
|
||||||
|
onMoveBookmarkToPrivate = { articleAddress ->
|
||||||
|
moveArticleBookmark(articleAddress, false)
|
||||||
|
},
|
||||||
onDeleteArticleBookmark = { articleAddress ->
|
onDeleteArticleBookmark = { articleAddress ->
|
||||||
deleteArticleBookmark(articleAddress, false)
|
deleteArticleBookmark(articleAddress, false)
|
||||||
},
|
},
|
||||||
@@ -66,6 +71,10 @@ fun RenderArticleList(
|
|||||||
ArticleList(
|
ArticleList(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
articles = privateArticles,
|
articles = privateArticles,
|
||||||
|
isArticleBookmarkPrivate = true,
|
||||||
|
onMoveBookmarkToPublic = { articleAddress ->
|
||||||
|
moveArticleBookmark(articleAddress, true)
|
||||||
|
},
|
||||||
onDeleteArticleBookmark = { articleAddress ->
|
onDeleteArticleBookmark = { articleAddress ->
|
||||||
deleteArticleBookmark(articleAddress, true)
|
deleteArticleBookmark(articleAddress, true)
|
||||||
},
|
},
|
||||||
@@ -80,6 +89,9 @@ fun RenderArticleList(
|
|||||||
fun ArticleList(
|
fun ArticleList(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
articles: List<AddressableNote>,
|
articles: List<AddressableNote>,
|
||||||
|
isArticleBookmarkPrivate: Boolean,
|
||||||
|
onMoveBookmarkToPublic: (articleAddress: Address) -> Unit = {},
|
||||||
|
onMoveBookmarkToPrivate: (articleAddress: Address) -> Unit = {},
|
||||||
onDeleteArticleBookmark: (Address) -> Unit,
|
onDeleteArticleBookmark: (Address) -> Unit,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
@@ -101,6 +113,9 @@ fun ArticleList(
|
|||||||
moreOptions = {
|
moreOptions = {
|
||||||
BookmarkGroupItemOptions(
|
BookmarkGroupItemOptions(
|
||||||
baseNote = item,
|
baseNote = item,
|
||||||
|
isBookmarkItemPrivate = isArticleBookmarkPrivate,
|
||||||
|
onMoveBookmarkToPublic = { onMoveBookmarkToPublic(item.address) },
|
||||||
|
onMoveBookmarkToPrivate = { onMoveBookmarkToPrivate(item.address) },
|
||||||
onDeleteBookmarkItem = {
|
onDeleteBookmarkItem = {
|
||||||
onDeleteArticleBookmark(item.address)
|
onDeleteArticleBookmark(item.address)
|
||||||
},
|
},
|
||||||
|
|||||||
+13
-5
@@ -60,6 +60,9 @@ import kotlinx.coroutines.launch
|
|||||||
@Composable
|
@Composable
|
||||||
fun BookmarkGroupItemOptions(
|
fun BookmarkGroupItemOptions(
|
||||||
baseNote: Note,
|
baseNote: Note,
|
||||||
|
isBookmarkItemPrivate: Boolean,
|
||||||
|
onMoveBookmarkToPublic: () -> Unit,
|
||||||
|
onMoveBookmarkToPrivate: () -> Unit,
|
||||||
onDeleteBookmarkItem: () -> Unit,
|
onDeleteBookmarkItem: () -> Unit,
|
||||||
editState: State<GenericLoadable<EditState>>? = null,
|
editState: State<GenericLoadable<EditState>>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
@@ -76,7 +79,10 @@ fun BookmarkGroupItemOptions(
|
|||||||
if (popupExpanded.value) {
|
if (popupExpanded.value) {
|
||||||
BookmarkGroupItemOptionsMenu(
|
BookmarkGroupItemOptionsMenu(
|
||||||
note = baseNote,
|
note = baseNote,
|
||||||
|
isBookmarkItemPrivate = isBookmarkItemPrivate,
|
||||||
onDismiss = { popupExpanded.value = false },
|
onDismiss = { popupExpanded.value = false },
|
||||||
|
onMoveBookmarkToPublic = onMoveBookmarkToPublic,
|
||||||
|
onMoveBookmarkToPrivate = onMoveBookmarkToPrivate,
|
||||||
onDeleteBookmarkItem = onDeleteBookmarkItem,
|
onDeleteBookmarkItem = onDeleteBookmarkItem,
|
||||||
editState = editState,
|
editState = editState,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
@@ -89,7 +95,10 @@ fun BookmarkGroupItemOptions(
|
|||||||
@Composable
|
@Composable
|
||||||
fun BookmarkGroupItemOptionsMenu(
|
fun BookmarkGroupItemOptionsMenu(
|
||||||
note: Note,
|
note: Note,
|
||||||
|
isBookmarkItemPrivate: Boolean,
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
|
onMoveBookmarkToPublic: () -> Unit,
|
||||||
|
onMoveBookmarkToPrivate: () -> Unit,
|
||||||
onDeleteBookmarkItem: () -> Unit,
|
onDeleteBookmarkItem: () -> Unit,
|
||||||
editState: State<GenericLoadable<EditState>>? = null,
|
editState: State<GenericLoadable<EditState>>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
@@ -149,6 +158,10 @@ fun BookmarkGroupItemOptionsMenu(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringRes(if (isBookmarkItemPrivate) R.string.move_bookmark_to_public_label else R.string.move_bookmark_to_private_label)) },
|
||||||
|
onClick = if (isBookmarkItemPrivate) onMoveBookmarkToPublic else onMoveBookmarkToPrivate,
|
||||||
|
)
|
||||||
DropdownMenuItem(
|
DropdownMenuItem(
|
||||||
text = { Text(stringRes(R.string.bookmark_remove_action_label)) },
|
text = { Text(stringRes(R.string.bookmark_remove_action_label)) },
|
||||||
onClick = {
|
onClick = {
|
||||||
@@ -156,11 +169,6 @@ fun BookmarkGroupItemOptionsMenu(
|
|||||||
onDismiss()
|
onDismiss()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
// TODO: Work on moving feature below
|
|
||||||
// DropdownMenuItem(
|
|
||||||
// text = { Text("Move to Public") },
|
|
||||||
// onClick =
|
|
||||||
// )
|
|
||||||
HorizontalDivider(thickness = DividerThickness)
|
HorizontalDivider(thickness = DividerThickness)
|
||||||
|
|
||||||
if (!state.isFollowingAuthor) {
|
if (!state.isFollowingAuthor) {
|
||||||
|
|||||||
+18
@@ -162,6 +162,15 @@ fun BookmarkGroupScreenView(
|
|||||||
bookmarkGroupViewModel,
|
bookmarkGroupViewModel,
|
||||||
pagerState,
|
pagerState,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
movePostBookmark = { postId, isPrivate ->
|
||||||
|
accountViewModel.launchSigner {
|
||||||
|
bookmarkGroupViewModel.movePostBookmark(
|
||||||
|
groupIdentifier = bookmarkGroupViewModel.bookmarkGroupIdentifier,
|
||||||
|
postId = postId,
|
||||||
|
isCurrentlyPrivate = isPrivate,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
deletePostBookmark = { postId, isPrivate ->
|
deletePostBookmark = { postId, isPrivate ->
|
||||||
accountViewModel.launchSigner {
|
accountViewModel.launchSigner {
|
||||||
bookmarkGroupViewModel.removePostBookmark(
|
bookmarkGroupViewModel.removePostBookmark(
|
||||||
@@ -178,6 +187,15 @@ fun BookmarkGroupScreenView(
|
|||||||
bookmarkGroupViewModel,
|
bookmarkGroupViewModel,
|
||||||
pagerState,
|
pagerState,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
moveArticleBookmark = { articleAddress, isPrivate ->
|
||||||
|
accountViewModel.launchSigner {
|
||||||
|
bookmarkGroupViewModel.moveArticleBookmark(
|
||||||
|
groupIdentifier = bookmarkGroupViewModel.bookmarkGroupIdentifier,
|
||||||
|
articleAddress = articleAddress,
|
||||||
|
isCurrentlyPrivate = isPrivate,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
deleteArticleBookmark = { articleAddress, isPrivate ->
|
deleteArticleBookmark = { articleAddress, isPrivate ->
|
||||||
accountViewModel.launchSigner {
|
accountViewModel.launchSigner {
|
||||||
bookmarkGroupViewModel.removeArticleBookmark(
|
bookmarkGroupViewModel.removeArticleBookmark(
|
||||||
|
|||||||
+31
-2
@@ -69,8 +69,6 @@ class BookmarkGroupViewModel(
|
|||||||
.map { group -> group.privateArticleBookmarks.map { account.cache.getOrCreateAddressableNote(it.address) } }
|
.map { group -> group.privateArticleBookmarks.map { account.cache.getOrCreateAddressableNote(it.address) } }
|
||||||
.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList())
|
.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList())
|
||||||
|
|
||||||
// TODO: Add implementations for Hashtag and Link bookmarks
|
|
||||||
|
|
||||||
suspend fun deleteBookmarkGroup(groupIdentifier: String) {
|
suspend fun deleteBookmarkGroup(groupIdentifier: String) {
|
||||||
account.labeledBookmarkLists.deleteBookmarkList(groupIdentifier, account)
|
account.labeledBookmarkLists.deleteBookmarkList(groupIdentifier, account)
|
||||||
}
|
}
|
||||||
@@ -88,6 +86,37 @@ class BookmarkGroupViewModel(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun movePostBookmark(
|
||||||
|
groupIdentifier: String = bookmarkGroupIdentifier,
|
||||||
|
postId: String,
|
||||||
|
isCurrentlyPrivate: Boolean,
|
||||||
|
) {
|
||||||
|
val eventBookmark = EventBookmark(postId)
|
||||||
|
moveBookmark(groupIdentifier, eventBookmark, isCurrentlyPrivate)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun moveArticleBookmark(
|
||||||
|
groupIdentifier: String = bookmarkGroupIdentifier,
|
||||||
|
articleAddress: Address,
|
||||||
|
isCurrentlyPrivate: Boolean,
|
||||||
|
) {
|
||||||
|
val eventBookmark = AddressBookmark(articleAddress)
|
||||||
|
moveBookmark(groupIdentifier, eventBookmark, isCurrentlyPrivate)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun moveBookmark(
|
||||||
|
groupIdentifier: String = bookmarkGroupIdentifier,
|
||||||
|
bookmark: BookmarkIdTag,
|
||||||
|
isCurrentlyPrivate: Boolean,
|
||||||
|
) {
|
||||||
|
account.labeledBookmarkLists.moveBookmarkInList(
|
||||||
|
bookmark,
|
||||||
|
groupIdentifier,
|
||||||
|
isCurrentlyPrivate,
|
||||||
|
account,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun removePostBookmark(
|
suspend fun removePostBookmark(
|
||||||
groupIdentifier: String = bookmarkGroupIdentifier,
|
groupIdentifier: String = bookmarkGroupIdentifier,
|
||||||
bookmarkPostId: String,
|
bookmarkPostId: String,
|
||||||
|
|||||||
+15
@@ -42,6 +42,7 @@ fun RenderPostList(
|
|||||||
bookmarkGroupViewModel: BookmarkGroupViewModel,
|
bookmarkGroupViewModel: BookmarkGroupViewModel,
|
||||||
pagerState: PagerState,
|
pagerState: PagerState,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
movePostBookmark: (postId: String, fromPrivate: Boolean) -> Unit,
|
||||||
deletePostBookmark: (postId: String, isPrivate: Boolean) -> Unit,
|
deletePostBookmark: (postId: String, isPrivate: Boolean) -> Unit,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
@@ -55,6 +56,10 @@ fun RenderPostList(
|
|||||||
PostList(
|
PostList(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
posts = publicPosts,
|
posts = publicPosts,
|
||||||
|
isPostBookmarkPrivate = false,
|
||||||
|
onMoveBookmarkToPrivate = { postId ->
|
||||||
|
movePostBookmark(postId, false)
|
||||||
|
},
|
||||||
onDeletePostBookmark = { postId ->
|
onDeletePostBookmark = { postId ->
|
||||||
deletePostBookmark(postId, false)
|
deletePostBookmark(postId, false)
|
||||||
},
|
},
|
||||||
@@ -65,6 +70,10 @@ fun RenderPostList(
|
|||||||
PostList(
|
PostList(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
posts = privatePosts,
|
posts = privatePosts,
|
||||||
|
isPostBookmarkPrivate = true,
|
||||||
|
onMoveBookmarkToPublic = { postId ->
|
||||||
|
movePostBookmark(postId, true)
|
||||||
|
},
|
||||||
onDeletePostBookmark = { postId ->
|
onDeletePostBookmark = { postId ->
|
||||||
deletePostBookmark(postId, true)
|
deletePostBookmark(postId, true)
|
||||||
},
|
},
|
||||||
@@ -79,6 +88,9 @@ fun RenderPostList(
|
|||||||
private fun PostList(
|
private fun PostList(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
posts: List<Note>,
|
posts: List<Note>,
|
||||||
|
isPostBookmarkPrivate: Boolean,
|
||||||
|
onMoveBookmarkToPublic: (postId: String) -> Unit = {},
|
||||||
|
onMoveBookmarkToPrivate: (postId: String) -> Unit = {},
|
||||||
onDeletePostBookmark: (postId: String) -> Unit,
|
onDeletePostBookmark: (postId: String) -> Unit,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
@@ -100,6 +112,9 @@ private fun PostList(
|
|||||||
moreOptions = {
|
moreOptions = {
|
||||||
BookmarkGroupItemOptions(
|
BookmarkGroupItemOptions(
|
||||||
baseNote = item,
|
baseNote = item,
|
||||||
|
isBookmarkItemPrivate = isPostBookmarkPrivate,
|
||||||
|
onMoveBookmarkToPublic = { onMoveBookmarkToPublic(item.idHex) },
|
||||||
|
onMoveBookmarkToPrivate = { onMoveBookmarkToPrivate(item.idHex) },
|
||||||
onDeleteBookmarkItem = { onDeletePostBookmark(item.idHex) },
|
onDeleteBookmarkItem = { onDeletePostBookmark(item.idHex) },
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
|
|||||||
+17
-19
@@ -32,8 +32,6 @@ import androidx.compose.foundation.layout.offset
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.outlined.Article
|
import androidx.compose.material.icons.automirrored.outlined.Article
|
||||||
import androidx.compose.material.icons.outlined.CollectionsBookmark
|
import androidx.compose.material.icons.outlined.CollectionsBookmark
|
||||||
import androidx.compose.material.icons.outlined.Lock
|
|
||||||
import androidx.compose.material.icons.outlined.Public
|
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.DropdownMenu
|
import androidx.compose.material3.DropdownMenu
|
||||||
@@ -70,6 +68,7 @@ import com.vitorpamplona.amethyst.ui.theme.Size40Modifier
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.Size5dp
|
import com.vitorpamplona.amethyst.ui.theme.Size5dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.SpacedBy2dp
|
import com.vitorpamplona.amethyst.ui.theme.SpacedBy2dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.SpacedBy5dp
|
import com.vitorpamplona.amethyst.ui.theme.SpacedBy5dp
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun BookmarkGroupItem(
|
fun BookmarkGroupItem(
|
||||||
@@ -135,13 +134,12 @@ fun BookmarkGroupItem(
|
|||||||
contentDescription = stringRes(R.string.bookmark_list_icon_label),
|
contentDescription = stringRes(R.string.bookmark_list_icon_label),
|
||||||
modifier = Size40Modifier,
|
modifier = Size40Modifier,
|
||||||
)
|
)
|
||||||
// TODO: Fix the component below, with per-category stats
|
Spacer(StdVertSpacer)
|
||||||
// Spacer(StdVertSpacer)
|
BookmarkMembershipStatusAndNumberDisplay(
|
||||||
// BookmarkMembershipStatusAndNumberDisplay(
|
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||||
// modifier = Modifier.align(Alignment.CenterHorizontally),
|
postBookmarksSize = bookmarkList.publicPostBookmarks.size + bookmarkList.privatePostBookmarks.size,
|
||||||
// privateBookmarksSize = bookmarkList.privateBookmarks.size,
|
articleBookmarksSize = bookmarkList.publicArticleBookmarks.size + bookmarkList.privateArticleBookmarks.size,
|
||||||
// publicBookmarksSize = bookmarkList.publicBookmarks.size,
|
)
|
||||||
// )
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -193,49 +191,49 @@ private fun BookmarkGroupActions(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun BookmarkMembershipStatusAndNumberDisplay(
|
fun BookmarkMembershipStatusAndNumberDisplay(
|
||||||
modifier: Modifier,
|
modifier: Modifier = Modifier,
|
||||||
privateBookmarksSize: Int,
|
postBookmarksSize: Int,
|
||||||
publicBookmarksSize: Int,
|
articleBookmarksSize: Int,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = modifier.offset(y = (-5).dp),
|
modifier = modifier.offset(y = (-5).dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = SpacedBy5dp,
|
horizontalArrangement = SpacedBy5dp,
|
||||||
) {
|
) {
|
||||||
if (privateBookmarksSize <= 0 && publicBookmarksSize <= 0) {
|
if (postBookmarksSize <= 0 && articleBookmarksSize <= 0) {
|
||||||
Text(
|
Text(
|
||||||
text = stringRes(R.string.follow_set_empty_label2),
|
text = stringRes(R.string.follow_set_empty_label2),
|
||||||
fontSize = Font10SP,
|
fontSize = Font10SP,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
if (privateBookmarksSize > 0) {
|
if (postBookmarksSize > 0) {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = SpacedBy2dp,
|
horizontalArrangement = SpacedBy2dp,
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.Lock,
|
painter = painterResource(R.drawable.post),
|
||||||
modifier = Size10Modifier,
|
modifier = Size10Modifier,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = privateBookmarksSize.toString(),
|
text = postBookmarksSize.toString(),
|
||||||
fontSize = Font10SP,
|
fontSize = Font10SP,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (publicBookmarksSize > 0) {
|
if (articleBookmarksSize > 0) {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = SpacedBy2dp,
|
horizontalArrangement = SpacedBy2dp,
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.Public,
|
imageVector = Icons.AutoMirrored.Outlined.Article,
|
||||||
modifier = Size10Modifier,
|
modifier = Size10Modifier,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = publicBookmarksSize.toString(),
|
text = articleBookmarksSize.toString(),
|
||||||
fontSize = Font10SP,
|
fontSize = Font10SP,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -110,6 +110,8 @@ private fun ListManagementView(
|
|||||||
listTitle = bookmarkList.title,
|
listTitle = bookmarkList.title,
|
||||||
isPublicMemberBookmark = maybePublicBookmark != null,
|
isPublicMemberBookmark = maybePublicBookmark != null,
|
||||||
isPrivateMemberBookmark = maybePrivateBookmark != null,
|
isPrivateMemberBookmark = maybePrivateBookmark != null,
|
||||||
|
totalPostBookmarkSize = bookmarkList.publicPostBookmarks.size + bookmarkList.privatePostBookmarks.size,
|
||||||
|
totalArticleBookmarkSize = bookmarkList.publicArticleBookmarks.size + bookmarkList.privateArticleBookmarks.size,
|
||||||
onClick = { nav.nav(Route.BookmarkGroupView(bookmarkList.identifier, BookmarkType.ArticleBookmark)) },
|
onClick = { nav.nav(Route.BookmarkGroupView(bookmarkList.identifier, BookmarkType.ArticleBookmark)) },
|
||||||
onAddBookmarkToGroup = { shouldBePrivate ->
|
onAddBookmarkToGroup = { shouldBePrivate ->
|
||||||
accountViewModel.launchSigner {
|
accountViewModel.launchSigner {
|
||||||
|
|||||||
+13
-3
@@ -23,9 +23,9 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.bookmarkgroups.membershipM
|
|||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.BookmarkAdd
|
import androidx.compose.material.icons.filled.BookmarkAdd
|
||||||
@@ -48,11 +48,13 @@ import androidx.compose.ui.Alignment
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.bookmarkgroups.list.BookmarkMembershipStatusAndNumberDisplay
|
||||||
import com.vitorpamplona.amethyst.ui.stringRes
|
import com.vitorpamplona.amethyst.ui.stringRes
|
||||||
import com.vitorpamplona.amethyst.ui.theme.HalfHalfVertPadding
|
import com.vitorpamplona.amethyst.ui.theme.HalfHalfVertPadding
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size15Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size15Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size50Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size50Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.SpacedBy5dp
|
import com.vitorpamplona.amethyst.ui.theme.SpacedBy5dp
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun BookmarkGroupManagementItem(
|
fun BookmarkGroupManagementItem(
|
||||||
@@ -60,6 +62,8 @@ fun BookmarkGroupManagementItem(
|
|||||||
listTitle: String,
|
listTitle: String,
|
||||||
isPrivateMemberBookmark: Boolean,
|
isPrivateMemberBookmark: Boolean,
|
||||||
isPublicMemberBookmark: Boolean,
|
isPublicMemberBookmark: Boolean,
|
||||||
|
totalPostBookmarkSize: Int,
|
||||||
|
totalArticleBookmarkSize: Int,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
onAddBookmarkToGroup: (shouldBookmarkBePrivate: Boolean) -> Unit,
|
onAddBookmarkToGroup: (shouldBookmarkBePrivate: Boolean) -> Unit,
|
||||||
onRemoveBookmarkFromGroup: () -> Unit,
|
onRemoveBookmarkFromGroup: () -> Unit,
|
||||||
@@ -77,14 +81,20 @@ fun BookmarkGroupManagementItem(
|
|||||||
BookmarkStatusInList(isPublicMemberBookmark, isPrivateMemberBookmark)
|
BookmarkStatusInList(isPublicMemberBookmark, isPrivateMemberBookmark)
|
||||||
},
|
},
|
||||||
leadingContent = {
|
leadingContent = {
|
||||||
Box(
|
Column(
|
||||||
contentAlignment = Alignment.Center,
|
verticalArrangement = Arrangement.Center,
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.CollectionsBookmark,
|
imageVector = Icons.Outlined.CollectionsBookmark,
|
||||||
contentDescription = stringRes(R.string.bookmark_list_icon_label),
|
contentDescription = stringRes(R.string.bookmark_list_icon_label),
|
||||||
modifier = Size50Modifier,
|
modifier = Size50Modifier,
|
||||||
)
|
)
|
||||||
|
Spacer(StdVertSpacer)
|
||||||
|
BookmarkMembershipStatusAndNumberDisplay(
|
||||||
|
postBookmarksSize = totalPostBookmarkSize,
|
||||||
|
articleBookmarksSize = totalArticleBookmarkSize,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
trailingContent = {
|
trailingContent = {
|
||||||
|
|||||||
+2
@@ -109,6 +109,8 @@ private fun ListManagementView(
|
|||||||
listTitle = bookmarkList.title,
|
listTitle = bookmarkList.title,
|
||||||
isPublicMemberBookmark = maybePublicBookmark != null,
|
isPublicMemberBookmark = maybePublicBookmark != null,
|
||||||
isPrivateMemberBookmark = maybePrivateBookmark != null,
|
isPrivateMemberBookmark = maybePrivateBookmark != null,
|
||||||
|
totalPostBookmarkSize = bookmarkList.publicPostBookmarks.size + bookmarkList.privatePostBookmarks.size,
|
||||||
|
totalArticleBookmarkSize = bookmarkList.publicArticleBookmarks.size + bookmarkList.privateArticleBookmarks.size,
|
||||||
onClick = { nav.nav(Route.BookmarkGroupView(bookmarkList.identifier, BookmarkType.PostBookmark)) },
|
onClick = { nav.nav(Route.BookmarkGroupView(bookmarkList.identifier, BookmarkType.PostBookmark)) },
|
||||||
onAddBookmarkToGroup = { shouldBePrivate ->
|
onAddBookmarkToGroup = { shouldBePrivate ->
|
||||||
accountViewModel.launchSigner {
|
accountViewModel.launchSigner {
|
||||||
|
|||||||
@@ -422,6 +422,8 @@
|
|||||||
<string name="private_bookmark_add_action_label">Add as private bookmark</string>
|
<string name="private_bookmark_add_action_label">Add as private bookmark</string>
|
||||||
<string name="bookmark_remove_action_label">Remove from Bookmark List</string>
|
<string name="bookmark_remove_action_label">Remove from Bookmark List</string>
|
||||||
<string name="bookmark_list_explainer">Bookmark lists metadata can be seen by anyone on Nostr. Only your private members are encrypted.</string>
|
<string name="bookmark_list_explainer">Bookmark lists metadata can be seen by anyone on Nostr. Only your private members are encrypted.</string>
|
||||||
|
<string name="move_bookmark_to_public_label">Move to Public</string>
|
||||||
|
<string name="move_bookmark_to_private_label">Move to Private</string>
|
||||||
|
|
||||||
<string name="wallet_connect_service">Wallet Connect Service</string>
|
<string name="wallet_connect_service">Wallet Connect Service</string>
|
||||||
<string name="wallet_connect_service_explainer">Authorizes a Nostr Secret to pay zaps without leaving the app. Keep the secret safe and use a private relay if possible</string>
|
<string name="wallet_connect_service_explainer">Authorizes a Nostr Secret to pay zaps without leaving the app. Keep the secret safe and use a private relay if possible</string>
|
||||||
|
|||||||
+25
@@ -144,6 +144,31 @@ class LabeledBookmarkListEvent(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun moveBookmark(
|
||||||
|
earlierVersion: LabeledBookmarkListEvent,
|
||||||
|
bookmarkIdTag: BookmarkIdTag,
|
||||||
|
isCurrentlyPrivate: Boolean,
|
||||||
|
signer: NostrSigner,
|
||||||
|
createdAt: Long = TimeUtils.now(),
|
||||||
|
): LabeledBookmarkListEvent =
|
||||||
|
if (isCurrentlyPrivate) {
|
||||||
|
val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException()
|
||||||
|
resign(
|
||||||
|
privateTags = privateTags.remove(bookmarkIdTag.toTagArray()),
|
||||||
|
tags = earlierVersion.tags.plus(bookmarkIdTag.toTagArray()),
|
||||||
|
signer = signer,
|
||||||
|
createdAt = createdAt,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException()
|
||||||
|
resign(
|
||||||
|
privateTags = privateTags.plus(bookmarkIdTag.toTagArray()),
|
||||||
|
tags = earlierVersion.tags.remove(bookmarkIdTag.toTagArray()),
|
||||||
|
signer = signer,
|
||||||
|
createdAt = createdAt,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun removeBookmark(
|
suspend fun removeBookmark(
|
||||||
earlierVersion: LabeledBookmarkListEvent,
|
earlierVersion: LabeledBookmarkListEvent,
|
||||||
bookmarkIdTag: BookmarkIdTag,
|
bookmarkIdTag: BookmarkIdTag,
|
||||||
|
|||||||
Reference in New Issue
Block a user