Skip to content

Commit

Permalink
Merge pull request #1576 from planetary-social/add-mention-button
Browse files Browse the repository at this point in the history
Add mention button to note composer
  • Loading branch information
pelumy authored Oct 4, 2024
2 parents 8b51a24 + a0877f9 commit c3fb373
Show file tree
Hide file tree
Showing 21 changed files with 35 additions and 94 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Release Notes
- Disable autocorrect on NoteComposer when running on macOS. [#1460](https://github.com/planetary-social/nos/issues/1460)
- Add @ button to the Note Composer. [#1561](https://github.com/planetary-social/nos/issues/1561)

### Internal Changes
- Show WebP images without link preview overlay. Currently behind the “Enable new media display” feature flag. [#1488](https://github.com/planetary-social/nos/issues/1488)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,52 +1,8 @@
{
"images" : [
{
"filename" : "add_images--light.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "add_images--dark.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
"filename" : "attach-media-button.pdf",
"idiom" : "universal"
}
],
"info" : {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,52 +1,8 @@
{
"images" : [
{
"filename" : "disappearing--light.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "disappearing--dark.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
"filename" : "disappearing-messages.pdf",
"idiom" : "universal"
}
],
"info" : {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
12 changes: 12 additions & 0 deletions Nos/Assets/Assets.xcassets/mention.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "mention.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
8 changes: 6 additions & 2 deletions Nos/Controller/NoteEditorController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import UIKit
}

/// Whether the user has entered any text.
var isEmpty: Bool = true
var isEmpty = true

/// The attributed text the user has entered.
var text: AttributedString? {
if let textView {
Expand Down Expand Up @@ -71,6 +71,10 @@ import UIKit
attributedString.replaceCharacters(in: range, with: appendedAttributedString)
textView.attributedText = attributedString
textView.selectedRange.location += appendedAttributedString.length

/// Check if `@` was appended and show the mentionsAutoComplete list.
guard text == "@" else { return }
showMentionsAutocomplete = true
}

/// Appends the given URL and adds the default link styling attributes. Will append a space before the link
Expand Down
12 changes: 12 additions & 0 deletions Nos/Views/NoteComposer/ComposerActionBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ struct ComposerActionBar: View {
if !showPreview {
attachMediaView
expirationTimeView
mentionButton
}
Spacer()
previewToggle
Expand Down Expand Up @@ -160,6 +161,17 @@ struct ComposerActionBar: View {
}
}

/// Inserts a mention (`@`) symbol into the text editor.
private var mentionButton: some View {
Button {
editingController.append(text: "@")
} label: {
Image.mention
.foregroundColor(.secondaryTxt)
.frame(minWidth: 44, minHeight: 44)
}
}

/// Uploads an image at the given URL to a file storage service.
/// - Parameter imageURL: File URL of the image the user wants to upload.
private func uploadImage(
Expand Down

0 comments on commit c3fb373

Please sign in to comment.